1.0.1 • Published 6 years ago

ngx-editable-list v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

ngx-editable-list

Angular 7 component for displaying and editing lists of items.

It gets an array of EditableListItem and displays items, showing Edit and Delete buttons right after each one. You can also add an item by clicking Add button screenshot ##Installation Install via NPM:

npm install ngx-editable-list --save

Import EditableListModule into your application:

import { EditableListModule } from 'ngx-editable-list';

@NgModule({
  ...
  imports: [EditableListModule]
  ...
})

*Insert these Sass styles in your global styles file(usually it's src/styles.scss):

 @import '~@angular/material/theming';
 @include mat-core();
 
 $candy-app-primary: mat-palette($mat-deep-purple); // you may change primary color
 $candy-app-accent: mat-palette($mat-amber); // you may change secondary color
 $candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent);
 
 @include mat-core-theme($candy-app-theme);
 @include mat-button-theme($candy-app-theme);
 @include mat-icon-theme($candy-app-theme);
 @include mat-dialog-theme($candy-app-theme);

You can change primary and accent colors, but make sure to have last 4 @include's as they are necessary for correct displaying of material components

- If you are already using prebuilt or custom material theme including last 4 imports, just ignore step 3*

API

EditableListItem's structure is following:

interface EditableListItem {
  id: number;
  category?: string;
  value: string
} 

Inputs

Customize component as you wish. Translate component into another language, if it's necessary.

ParameterOptionsDefaultDescription
itemsEditableListItem[][]List of items which you can provide to component
confirmItemRemovaltrue,falsetrueIf true, every click on Delete button will show a dialog asking to confirm action, if false, items will be deleted immediately
enableCategoriestrue,falsefalseIf true, every EditableListItem will require to have category field when editing or adding an item
title--Title of a list
labelAdd-Add itemLabel of Add item button
labelEdit-EditLabel of Edit item button
labelRemove-RemoveLabel of Remove item button
labelConfirm-ConfirmLabel of Confirm button inside dialog
labelCancel-CancelLabel of Cancel button inside dialog
removeModalQuestion-Remove item?Question showing inside dialog

Events

Events are useful for synchronizing list changes with your backend.

EventOutput
addedEditableListItem
editedEditableListItem
removedEditableListItem

Questions? Suggestions?

This is my first open-source sharing, so code quality or documentation could have some problems.

Feel free to pull request or email me: meshkov.ra@ya.ru