Clear code and optimized js-sample

This commit is contained in:
Vladyslav_Prykhodko 2020-06-11 10:00:37 +03:00
parent accd98676f
commit a2aa854378
2 changed files with 30 additions and 38 deletions

View File

@ -62,14 +62,14 @@
<!-- <mat-form-field fxFlex class="mat-block">--> <!-- <mat-form-field fxFlex class="mat-block">-->
<!-- <mat-label>Integer Value</mat-label>--> <!-- <mat-label>Integer Value</mat-label>-->
<!-- <input type="number" step="1" matInput formControlName="number">--> <!-- <input type="number" step="1" matInput formControlName="number">-->
<!-- <mat-error *ngIf="editEntityFormGroup.get('attributes').get('number').hasError('pattern')">--> <!-- <mat-error *ngIf="editEntityFormGroup.get('attributes.number').hasError('pattern')">-->
<!-- Invalid integer value.--> <!-- Invalid integer value.-->
<!-- </mat-error>--> <!-- </mat-error>-->
<!-- </mat-form-field>--> <!-- </mat-form-field>-->
<!-- <div class="boolean-value-input" fxLayout="column" fxLayoutAlign="center start" fxFlex>--> <!-- <div class="boolean-value-input" fxLayout="column" fxLayoutAlign="center start" fxFlex>-->
<!-- <label class="checkbox-label">Boolean Value</label>--> <!-- <label class="checkbox-label">Boolean Value</label>-->
<!-- <mat-checkbox formControlName="booleanValue" style="margin-bottom: 40px;">--> <!-- <mat-checkbox formControlName="booleanValue" style="margin-bottom: 40px;">-->
<!-- {{ (editEntityFormGroup.get('attributes').get('booleanValue').value ? "value.true" : "value.false") | translate }}--> <!-- {{ (editEntityFormGroup.get('attributes.booleanValue').value ? "value.true" : "value.false") | translate }}-->
<!-- </mat-checkbox>--> <!-- </mat-checkbox>-->
<!-- </div>--> <!-- </div>-->
<!-- </div>--> <!-- </div>-->
@ -184,7 +184,6 @@
<!-- Save--> <!-- Save-->
<!-- </button>--> <!-- </button>-->
<!-- <button mat-button color="primary"--> <!-- <button mat-button color="primary"-->
<!-- style="margin-right: 20px;"-->
<!-- type="button"--> <!-- type="button"-->
<!-- [disabled]="(isLoading$ | async)"--> <!-- [disabled]="(isLoading$ | async)"-->
<!-- (click)="cancel()" cdkFocusInitial>--> <!-- (click)="cancel()" cdkFocusInitial>-->
@ -270,14 +269,14 @@
<!-- <mat-form-field fxFlex class="mat-block">--> <!-- <mat-form-field fxFlex class="mat-block">-->
<!-- <mat-label>Integer Value</mat-label>--> <!-- <mat-label>Integer Value</mat-label>-->
<!-- <input type="number" step="1" matInput formControlName="number">--> <!-- <input type="number" step="1" matInput formControlName="number">-->
<!-- <mat-error *ngIf="addEntityFormGroup.get('attributes').get('number').hasError('pattern')">--> <!-- <mat-error *ngIf="addEntityFormGroup.get('attributes.number').hasError('pattern')">-->
<!-- Invalid integer value.--> <!-- Invalid integer value.-->
<!-- </mat-error>--> <!-- </mat-error>-->
<!-- </mat-form-field>--> <!-- </mat-form-field>-->
<!-- <div class="boolean-value-input" fxLayout="column" fxLayoutAlign="center start" fxFlex>--> <!-- <div class="boolean-value-input" fxLayout="column" fxLayoutAlign="center start" fxFlex>-->
<!-- <label class="checkbox-label">Boolean Value</label>--> <!-- <label class="checkbox-label">Boolean Value</label>-->
<!-- <mat-checkbox formControlName="booleanValue" style="margin-bottom: 40px;">--> <!-- <mat-checkbox formControlName="booleanValue" style="margin-bottom: 40px;">-->
<!-- {{ (addEntityFormGroup.get('attributes').get('booleanValue').value ? "value.true" : "value.false") | translate }}--> <!-- {{ (addEntityFormGroup.get('attributes.booleanValue').value ? "value.true" : "value.false") | translate }}-->
<!-- </mat-checkbox>--> <!-- </mat-checkbox>-->
<!-- </div>--> <!-- </div>-->
<!-- </div>--> <!-- </div>-->
@ -345,7 +344,6 @@
<!-- Create--> <!-- Create-->
<!-- </button>--> <!-- </button>-->
<!-- <button mat-button color="primary"--> <!-- <button mat-button color="primary"-->
<!-- style="margin-right: 20px;"-->
<!-- type="button"--> <!-- type="button"-->
<!-- [disabled]="(isLoading$ | async)"--> <!-- [disabled]="(isLoading$ | async)"-->
<!-- (click)="cancel()" cdkFocusInitial>--> <!-- (click)="cancel()" cdkFocusInitial>-->

View File

@ -186,28 +186,27 @@
// } // }
// //
// function getEntityInfo() { // function getEntityInfo() {
// entityService.getEntity(entityId.entityType, entityId.id).subscribe(function (entity) { // widgetContext.rxjs.forkJoin([
// vm.entity = entity; // entityRelationService.findInfoByFrom(entityId),
// widgetContext.rxjs.forkJoin([ // entityRelationService.findInfoByTo(entityId),
// entityRelationService.findInfoByFrom(entityId), // attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE'),
// entityRelationService.findInfoByTo(entityId), // entityService.getEntity(entityId.entityType, entityId.id)
// attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE') // ]).subscribe(
// ]).subscribe( // function (data) {
// function (data) { // getEntityRelations(data.slice(0,2));
// getEntityRelations(data.slice(0,2)); // getEntityAttributes(data[2]);
// getEntityAttributes(data[2]); // vm.entity = data[3];
// vm.editEntityFormGroup.patchValue({ // vm.editEntityFormGroup.patchValue({
// entityName: vm.entity.name, // entityName: vm.entity.name,
// entityType: vm.entityType, // entityType: vm.entityType,
// entityLabel: vm.entity.label, // entityLabel: vm.entity.label,
// type: vm.entity.type, // type: vm.entity.type,
// attributes: vm.attributes, // attributes: vm.attributes,
// oldRelations: vm.oldRelationsData // oldRelations: vm.oldRelationsData
// }, {emitEvent: false}); // }, {emitEvent: false});
// } // }
// ); // );
// }); // }
// }
// //
// function saveEntity() { // function saveEntity() {
// const formValues = vm.editEntityFormGroup.value; // const formValues = vm.editEntityFormGroup.value;
@ -218,9 +217,8 @@
// } else if (formValues.entityType == 'DEVICE') { // } else if (formValues.entityType == 'DEVICE') {
// return deviceService.saveDevice(vm.entity); // return deviceService.saveDevice(vm.entity);
// } // }
// } else {
// return widgetContext.rxjs.of([]);
// } // }
// return widgetContext.rxjs.of([]);
// } // }
// //
// function saveAttributes(entityId) { // function saveAttributes(entityId) {
@ -233,9 +231,8 @@
// } // }
// if (attributesArray.length > 0) { // if (attributesArray.length > 0) {
// return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray); // return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray);
// } else {
// return widgetContext.rxjs.of([]);
// } // }
// return widgetContext.rxjs.of([]);
// } // }
// //
// function saveRelations(entityId) { // function saveRelations(entityId) {
@ -270,9 +267,8 @@
// } // }
// if (tasks.length > 0) { // if (tasks.length > 0) {
// return widgetContext.rxjs.forkJoin(tasks); // return widgetContext.rxjs.forkJoin(tasks);
// } else {
// return widgetContext.rxjs.of([]);
// } // }
// return widgetContext.rxjs.of([]);
// } // }
//} //}
// //
@ -380,9 +376,8 @@
// } // }
// if (attributesArray.length > 0) { // if (attributesArray.length > 0) {
// return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray); // return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray);
// } else {
// return widgetContext.rxjs.of([]);
// } // }
// return widgetContext.rxjs.of([]);
// } // }
// //
// function saveRelations(entityId) { // function saveRelations(entityId) {
@ -404,8 +399,7 @@
// } // }
// if (tasks.length > 0) { // if (tasks.length > 0) {
// return widgetContext.rxjs.forkJoin(tasks); // return widgetContext.rxjs.forkJoin(tasks);
// } else {
// return widgetContext.rxjs.of([]);
// } // }
// return widgetContext.rxjs.of([]);
// } // }
//} //}