Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace myProject.Default {
- @Serenity.Decorators.registerClass()
- @Serenity.Decorators.panel()
- export class MatrixEditDialog extends Serenity.EntityDialog<MatrixRow, any> {
- protected getFormKey() { return MatrixForm.formKey; }
- protected getIdProperty() { return MatrixRow.idProperty; }
- protected getLocalTextPrefix() { return MatrixRow.localTextPrefix; }
- protected getNameProperty() { return MatrixRow.nameProperty; }
- protected getService() { return MatrixService.baseUrl; }
- protected form = new MatrixForm(this.idPrefix);
- constructor() {
- super();
- this.element.addClass('flex-layout');
- this.toggleRun();
- }
- static initializePage() {
- $(function () {
- new Default.MatrixEditDialog().element.appendTo($('#DialogDiv'));
- });
- };
- protected onSaveSuccess(response: Serenity.SaveResponse): void {
- super.onSaveSuccess(response);
- var cID = this.getSaveEntity().CustomerId;
- var aID = this.getSaveEntity().AddressId;
- Q.confirm(
- "Add another item to the same room?",
- () => {
- Q.notifySuccess("You clicked YES.");
- newDialogwithVals(cID, aID);
- },
- {
- onNo: () => {
- Q.notifyInfo("You clicked NO.");
- $('#DialogDiv').empty();
- new Default.MatrixEditDialog().element.appendTo($('#DialogDiv'));
- },
- onCancel: () => {
- Q.notifyError("You clicked X. Operation is cancelled.");
- $('#DialogDiv').empty();
- new Default.MatrixEditDialog().element.appendTo($('#DialogDiv'));
- }
- });
- }
- protected toggleRun() {
- this.categoryToggler(this.form.CustomerId, 'Address');
- this.categoryToggler(this.form.AddressId, 'Accounting');
- this.categoryToggler(this.form.AddressId, 'Revision');
- this.categoryToggler(this.form.AddressId, 'General');
- this.categoryToggler(this.form.AddressId, 'Equipment Info');
- this.categoryToggler(this.form.AddressId, 'Plumbing');
- this.categoryToggler(this.form.AddressId, 'Mechanical');
- this.categoryToggler(this.form.AddressId, 'Electrical');
- this.categoryToggler(this.form.AddressId, 'Dimensions');
- this.categoryToggler(this.form.AddressId, 'Other');
- }
- protected categoryToggler(triggerField: Serenity.LookupEditor, categoryTitle: string) {
- var myTag = categoryTitle;
- var ele = this.element.find(".category-title:contains('" + myTag + "')").parent();
- var checkTrigger = triggerField.value;
- if (Q.isEmptyOrNull(checkTrigger)) {
- ele.toggle(false);
- triggerField.changeSelect2(e => {
- var myTrigger = triggerField.value;
- if (Q.isEmptyOrNull(myTrigger) === true) {
- ele.toggle(false);
- }
- else {
- ele.toggle(true);
- }
- });
- }
- else {
- triggerField.changeSelect2(e => {
- var myTrigger = triggerField.value;
- if (Q.isEmptyOrNull(myTrigger) === true) {
- ele.toggle(false);
- }
- else {
- ele.toggle(true);
- }
- });
- }
- };
- }
- function newDialogwithVals(customerID: number, addressID: number)
- {
- $('#DialogDiv').empty();
- var dlg = new MatrixEditDialog();
- dlg.loadEntityAndOpenDialog(<MatrixRow>{
- CustomerId: customerID,
- AddressId: addressID,
- Status: 1,
- ProvidedBy: 1,
- InstalledBy: 1
- });
- dlg.element.appendTo($('#DialogDiv'));
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement