0.0.1 • Published 4 years ago

ngx-table-generator v0.0.1

Weekly downloads
4
License
-
Repository
-
Last release
4 years ago

Table generator

Introduction

Install the generator:

    npm install --save ngx-table-generator

This component generates a table with options such as suboperations, buttons, multicheck, receiving a configuration given by the developer.

Table generator

The module thtat contains the currency mask is this: TableGenerator. And it is used as follows (Inputs that appear in the example are mandatory):

<ngx-table-generator [dataSource]="dataSource" [dataColumnsTable]="dataColumnsTable" [sortOptions]="sortOption" [paginatorOption]="paginatorOption"></ngx-table-generator>

Inputs

InputTypeUsageMandatory
dataSourceMatTableDataSourceBasic object with dataSource structuremandatory
dataColumnsTableITableCell[]Array formed by objects containing the configuration of each column of the tablemandatory
sortOptionsISortOptionContains the basic sorting configurationmandatory
paginatorOptionIPaginatorOptionsContains the basic configuration of paginationmandatory
disabledMulticheckbooleanChecks if the multicheck button is disabledoptional
footerDataIFooterData[]Array containing object with the name and value of the fields to be displayed in the footeroptional
classMapstring[]Array with the name of the css classes to be added to the tableoptional
buttonOptionsIButtonOptions[]Array containing the configuration objects with the buttons to addoptional

Output

OutputTypeUsageMandatory
onPageEventEventEmitterEmits an event with each action on the paginationoptional
buttonEventEventEmitterEmits an event that contains the button you clickedoptional
rowClickEventEmitterEmits an event with the column information that is clickedoptional
sortChangeEventEmitterEmits an event with each action on the sorteroptional
suboperationActionEventEmitterEmits an event with the event that has been executedoptional
trashActionEventEmitterEmits an event when you click on the delete buttonoptional
multiCheckActionEventEmitterEmits an event with an array with the selected rowsoptional

Interfaces

ITableColumn

InstanceTypeUsageMandatory
isCheckboxbooleanIndicates if the cell will be checkboxoptional
labelstringName of the headermandatory
namestringName of the column. (You must talk to the backend to name the name of the instance to receive in the json equal to the order parameter of that column, otherwise it will not work). The word btnSuboperations is reserved, which if placed in the first object of the array activates the suboperationsmandatory
showWhenstringIndicates whether the cell in that column should be visibleoptional
sortbooleanIndicates if the column is sortableoptional
multiCheckIMultiCheckOptionMulticheck optionsoptional
suboperationDataISuboperationData[]Suboperation optionsoptional
objectInstancesstring[]Array with the names of the instances to go throughoptional
isSharesbooleanIndicator if it is an shares (4 decimals)optional
isCurrencybooleanIndicator if it is an currency (2 decimals)optional

ISuboperationData

InstanceTypeUsageMandatory
labelstringName of suboperationmandatory
conditionalstring[]Array indicating which logical comparison to use ('<', '>', '===', '>=', '<=', '<day', '>day')optional
valueToComparestring[]Array with the value to compareoptional
itemToComparestring[]Array with the name of the instance to compareoptional

IMultiCheckOption

InstanceTypeUsageMandatory
idstringName of the instance that will fill the multicheck arraymandatory
buttonLabelstringMulticheck button namemandatory
multiMinSelectedstringSelectable minimum checkoptional
conditionalMulticheckstring[]Array indicating which logical comparison to use ('<', '>', '===', '>=', '<=', '<day', '>day')optional
keysMulticheckstring[]Array with the name of the instance to compareoptional
valueMulticheckToCompareany[]Array with the value to compareoptional

ISortOption

InstanceTypeUsageMandatory
activeSortstringIndicates if the order is activeoptional
directionstringIndicates default directionoptional

IPaginatorOptions

InstanceTypeUsageMandatory
resultsLengthstringResult size per pagemandatory
limitstringLimit of rows per pageoptional

IFooterData

InstanceTypeUsageMandatory
namestringName of footerdatamandatory
valuenumberValue of footerdataoptional

IButtonOptions

InstanceTypeUsageMandatory
iconstringname of icon to be displayed (material icon)optional
labelstringName of buttonmandatory
eventstringName of eventmandatory
buttonConditionsIConditionsOptionButton optionsoptional

IConditionsOption

InstanceTypeUsageMandatory
valuestringValue to compareoptional
conditionstringArray indicating which logical comparison to use ('<', '>', '===', '>=', '<=', '<day', '>day')mandatory

Example

Config table file

export namespace TableGlobalOrderView {
    export const dataColumnsTable = [
        {
            name: 'name',
            multiCheck: {
                id: 'multiCheck',
                buttonLabel: 'multiCheck',
                multiMinSelected: '-1',
                conditionalMulticheck: ['===',],
                keysMulticheck: ['test'],
                valueMulticheckToCompare: ['0']
            },
            suboperationData: [
                {
                    label: 'suboperationData1',
                    conditional: ['==='],
                    valueToCompare: ['0'],
                    itemToCompare: ['suboperationData1']
                },
                {
                    label: 'suboperationData2',
                    conditional: ['==='],
                    valueToCompare: ['true'],
                    itemToCompare: ['suboperationData2']
                },
                {
                    label: 'suboperationData3',
                    conditional: ['==='],
                    valueToCompare: ['N'],
                    itemToCompare: ['suboperationData3']
                }
            ],
        },
        {
            label: 'label1',
            name: 'name1',
            objectInstances: ['name1', 'name12'],
            sort: true
        },
        {
            label: 'label2',
            name: 'name2',
            date: true,
            sort: true
        },
        {
            label: 'label3',
            name: 'name3',
            sort: true
        },
        {
            label: 'label4',
            name: 'label4',
            objectToCompare: [{ id: 'N', label: 'No' }, { id: 'Y', label: 'Yes' }],
            sort: true
        },
        {
            label: 'label5',
            name: 'mame5',
            sort: true
        },
        {
            label: 'label6',
            name: 'name6',
            isShares: true,
            sort: true
        },
        {
            label: 'label7',
            name: 'name7',
            isShares: true,
            sort: true
        },
        {
            label: 'label8',
            name: 'name8',
            isCurrency: true,
            sort: true
        }
    ];
    export const paginatorOption = {
        resultsLength: 0,
        limit: 20,
    };

    export const sortOption = {
        activeSort: 'customerId',
        direction: 'asc'
    };

    export const buttonOptions = [
        { icon: 'note_add', label: 'New', event: 'new' },
        { icon: 'note_add', label: 'Delete', event: 'delete', buttonConditions: { value: '', condition: 4 } }
    ];
}