0.1.15 • Published 4 months ago

ddata-ui-dialog v0.1.15

Weekly downloads
7
License
-
Repository
-
Last release
4 months ago

DData UI Dialog

This module has two components for handle dialogs easier in ddata world.

Modal dialog with component

If you want to show a component in dialog and then handle events in dialog, you should use this component.

Usage

HTML

<button (click)="showDialog = true">Show dialog</button>

<dd-modal-dialog
  title="My awesome dialog title"
  [model]="model"
  [dialogContent]="dialogContent"
  [showDialog]="showDialog"
  [overlayClickCloseDialog]="false"
  closeButtonText="Close"
  (success)="save()"
  (fail)="cancel()"
  ></dd-modal-dialog>

TypeScript

@Component({
  selector: 'app-awesome-component',
  templateUrl: './awesome.component.html',
  styleUrls: ['./awesome.component.scss']
})
export class AwesomeComponent implements OnInit {
  model: BaseModelInterface = new BaseModel(); // your model definition
  showDialog = false;
  dialogContent: DialogContentInterface = {
    createEditComponent: ProductCreateEditComponent,
    createEditOptions: {
      // ...
    },
    listComponent: ProductListComponent,
    listOptions: {
      // ...
    },
  };

  ngOnInit(): void {
    // ...
  }

  save(): void {
    // ...
    this.showDialog = false;
  }

  cancel(): void {
    this.showDialog = false;
  }
}

API

InputTypeDefaultDescription
titlestringempty stringTitle of the dialog.
modelBaseModelWithoutTypeDefinitionInterfacenew BaseModel()Model of the dialog.
dialogContentDialogContentItemnew DialogContentItem(DdataUiNoDataComponent, {})Dialog type. Can be message, delete, warning or any other string.
showDialogfalsefalseDialog is visible or not.
overlayClickCloseDialogbooleantrueThe ovrelay div is clickable or not. If clickable it cause a pressed event with false.
closeButtonTextstringCloseTitle text of the close button.
OutputTypeDescription
successEventEmitter<BaseModelWithoutTypeDefinitionInterface>Emit when user clicks on the success button (OK, Yes, Agree, Allow, etc.) in your component.
failEventEmitter<string>Emit when user clicks on any button. The emitted value is depends on user clicked on success button (value is true) or not (value is false).

DialogContentInterface

NameRequiredTypeDefaultDescription
saveModelnoObservable<any>nullYou can define a custom observable what is emit when user click on your component's save button.
selectnoObservable<any>nullYou can define a custom observable what is emit when user select an element in your list.
isModalnobooleanfalseSet true if this is a modal dialog.
multipleSelectEnablednobooleanfalseIf this is a list component, you can control single select or multiple select lists behavioir.
isSelectionListnobooleanfalseIf this is a list component, you can control this is a selectable list component.
selectedElementsnoany[][]Define previously selected models.
modelsnoany[][]Define preloaded models.
loadDatanobooleanfalseControl data loading when your component is showed in the dialog. Set false if you have preloaded models to list component.
filternoany{}Control your search/filter parameters on the listed models.
datasArrivednonumber0Set a random number is datas arrived from the backend on the parent component.

Confirm dialog

If you wan to open a simple confirm or message dialog to the user, you should to use this component.

Usage

HTML

<dd-confirm-dialog
  title="Are you sure?"
  content="Are you sure to delete this element?"
  type="delete"
  successButtonText="Delete"
  cancelButtonText="Cancel"
  closeButtonText="Close"
  [isModalVisible]="showDeleteDialog"
  [overlayClickCloseDialog]="false"
  (confirm)="deleteIsConfirmed()"
  (pressed)="buttonPressedOnDialog($event)"
  ></dd-confirm-dialog>

TypeScript

@Component({
  selector: 'app-awesome-component',
  templateUrl: './awesome.component.html',
  styleUrls: ['./awesome.component.scss']
})
export class AwesomeComponent implements OnInit {
  showDeleteDialog = false;

  ngOnInit(): void {
    // ...
  }

  deleteIsConfirmed(): void {
    // delete button pressed...
  }

  buttonPressedOnDialog(isConfirmed: boolean): void {
    if (isConfirmed) {
      // delete button pressed...
    } else {
      // cancel or close button pressed...
    }
  }
}

API

InputTypeDefaultDescription
titlestringempty stringTitle of the dialog.
contentstringempty stringContent of the dialog.
typeDialogTypemessageDialog type. Can be message, delete, warning or any other string.
showDialogbooleanfalseDialog is visible or not.
overlayClickCloseDialogbooleantrueThe ovrelay div is clickable or not. If clickable it cause a pressed event with false.
successButtonTextstringOKText on the success button.
cancelButtonTextstringCancelText on the cancel button.
closeButtonTextstringCloseTitle text of the close button.
OutputTypeDescription
confirmEventEmitter<any>Emit when user clicks on the success button (OK, Yes, Agree, Allow, etc.)
pressedEventEmitter<boolean>Emit when user clicks on any button. The emitted value is depends on user clicked on success button (value is true) or not (value is false).
0.1.15

4 months ago

0.1.13

2 years ago

0.1.14

1 year ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.0.1

4 years ago