0.1.7 • Published 4 years ago

etools-table v0.1.7

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
4 years ago

\<etools-table>

LitElement based data table UI

Usage

        <etools-table .columns="${this.listColumns}"
                      .items="${this.listData}"
                      .paginator="${this.paginator}"
                      @paginator-change="${this.paginatorChange}"
                      @sort-change="${this.sortChange}">
        </etools-table>

        @property({type: Array})
        listColumns: EtoolsTableColumn[] = [
          {
            label: 'Reference No.',
            name: 'reference_number',
            link_tmpl: `${ROOT_PATH}items/:id/details`,
            type: EtoolsTableColumnType.Link
          },
          {
            label: 'Created Date',
            name: 'created_date',
            type: EtoolsTableColumnType.Date,
            sort: EtoolsTableColumnSort.Desc
          },
          {
            label: 'Partner Org',
            name: 'partner_name',
            type: EtoolsTableColumnType.Text,
            sort: EtoolsTableColumnSort.Asc
          },
          {
            label: 'Status',
            name: 'status',
            type: EtoolsTableColumnType.Text,
            capitalize: true
          },
          {
            label: 'Assessor',
            name: 'assessor',
            type: EtoolsTableColumnType.Text
          },
          {
            label: 'Priority',
            name: 'high_priority',
            type: EtoolsTableColumnType.Custom,
            customMethod: (item: any) => {return item.high_priority ? 'High' : '';}
          }
        ];

        paginatorChange(e: CustomEvent) {
          const newPaginator = {...e.detail};
          this.paginator = newPaginator;
          this.updateUrlListQueryParams();
        }

        sortChange(e: CustomEvent) {
          this.sort = getSortFields(e.detail);
          this.updateUrlListQueryParams();
        }

EtoolsTable

Custom propertyDescription
captiontable caption
dateFormatdate format to be used for columns of type EtoolsTableColumnType.Date, by default is 'D MMM YYYY'
actionsLabelif showEdit or showDelete is true at the end of the table it is added and extra column for actions, this property will set the column caption
showEditdisplay edit icon in the last column, on click will fire event edit-item
showDeletedisplay delete icon in the last column, on click will fire event delete-item
showCopydisplay copy icon in the last column, on click will fire event copy-item
columnsarray of EtoolsTableColumn, see below the properties
itemsarray of objects to be used for populating the table
paginatorof type EtoolsPaginator, not required, will fire event paginator-change

EtoolsTableColumn

Custom propertyDescription
labelcolumn header label
nameproperty name from item object
typecolumn type: EtoolsTableColumnType (Text, Date, Link, Number, Checkbox, Custom)
sortcolum sort: EtoolsTableColumnSort (Asc, Desc)
link_tmplused only for EtoolsTableColumnType.Link to specify url template (route with a single param), ex: ${ROOT_PATH}assessments/:id/details, id will be replaced with item object id property
isExternalLinkused by columns of Link type to specify if url is external,
capitalizecapitalize first letter
placeholderplaceholder to be used in case of missing data
customMethodbind custom method which will return cell output for more flexibility

EtoolsPaginator

Custom propertyDescription
page
page_size
total_pages
count
visible_range

Install

TODO: create npm package

$ npm i --save @unicef-polymer/etools-table
0.1.7

4 years ago

0.1.6

4 years ago

0.1.4

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago