Commit a2aa8543784386a544fb846bc1f1454ff978e08c

Authored by Vladyslav_Prykhodko
1 parent accd9867

Clear code and optimized js-sample

@@ -62,14 +62,14 @@ @@ -62,14 +62,14 @@
62 <!-- <mat-form-field fxFlex class="mat-block">--> 62 <!-- <mat-form-field fxFlex class="mat-block">-->
63 <!-- <mat-label>Integer Value</mat-label>--> 63 <!-- <mat-label>Integer Value</mat-label>-->
64 <!-- <input type="number" step="1" matInput formControlName="number">--> 64 <!-- <input type="number" step="1" matInput formControlName="number">-->
65 -<!-- <mat-error *ngIf="editEntityFormGroup.get('attributes').get('number').hasError('pattern')">--> 65 +<!-- <mat-error *ngIf="editEntityFormGroup.get('attributes.number').hasError('pattern')">-->
66 <!-- Invalid integer value.--> 66 <!-- Invalid integer value.-->
67 <!-- </mat-error>--> 67 <!-- </mat-error>-->
68 <!-- </mat-form-field>--> 68 <!-- </mat-form-field>-->
69 <!-- <div class="boolean-value-input" fxLayout="column" fxLayoutAlign="center start" fxFlex>--> 69 <!-- <div class="boolean-value-input" fxLayout="column" fxLayoutAlign="center start" fxFlex>-->
70 <!-- <label class="checkbox-label">Boolean Value</label>--> 70 <!-- <label class="checkbox-label">Boolean Value</label>-->
71 <!-- <mat-checkbox formControlName="booleanValue" style="margin-bottom: 40px;">--> 71 <!-- <mat-checkbox formControlName="booleanValue" style="margin-bottom: 40px;">-->
72 -<!-- {{ (editEntityFormGroup.get('attributes').get('booleanValue').value ? "value.true" : "value.false") | translate }}--> 72 +<!-- {{ (editEntityFormGroup.get('attributes.booleanValue').value ? "value.true" : "value.false") | translate }}-->
73 <!-- </mat-checkbox>--> 73 <!-- </mat-checkbox>-->
74 <!-- </div>--> 74 <!-- </div>-->
75 <!-- </div>--> 75 <!-- </div>-->
@@ -184,7 +184,6 @@ @@ -184,7 +184,6 @@
184 <!-- Save--> 184 <!-- Save-->
185 <!-- </button>--> 185 <!-- </button>-->
186 <!-- <button mat-button color="primary"--> 186 <!-- <button mat-button color="primary"-->
187 -<!-- style="margin-right: 20px;"-->  
188 <!-- type="button"--> 187 <!-- type="button"-->
189 <!-- [disabled]="(isLoading$ | async)"--> 188 <!-- [disabled]="(isLoading$ | async)"-->
190 <!-- (click)="cancel()" cdkFocusInitial>--> 189 <!-- (click)="cancel()" cdkFocusInitial>-->
@@ -270,14 +269,14 @@ @@ -270,14 +269,14 @@
270 <!-- <mat-form-field fxFlex class="mat-block">--> 269 <!-- <mat-form-field fxFlex class="mat-block">-->
271 <!-- <mat-label>Integer Value</mat-label>--> 270 <!-- <mat-label>Integer Value</mat-label>-->
272 <!-- <input type="number" step="1" matInput formControlName="number">--> 271 <!-- <input type="number" step="1" matInput formControlName="number">-->
273 -<!-- <mat-error *ngIf="addEntityFormGroup.get('attributes').get('number').hasError('pattern')">--> 272 +<!-- <mat-error *ngIf="addEntityFormGroup.get('attributes.number').hasError('pattern')">-->
274 <!-- Invalid integer value.--> 273 <!-- Invalid integer value.-->
275 <!-- </mat-error>--> 274 <!-- </mat-error>-->
276 <!-- </mat-form-field>--> 275 <!-- </mat-form-field>-->
277 <!-- <div class="boolean-value-input" fxLayout="column" fxLayoutAlign="center start" fxFlex>--> 276 <!-- <div class="boolean-value-input" fxLayout="column" fxLayoutAlign="center start" fxFlex>-->
278 <!-- <label class="checkbox-label">Boolean Value</label>--> 277 <!-- <label class="checkbox-label">Boolean Value</label>-->
279 <!-- <mat-checkbox formControlName="booleanValue" style="margin-bottom: 40px;">--> 278 <!-- <mat-checkbox formControlName="booleanValue" style="margin-bottom: 40px;">-->
280 -<!-- {{ (addEntityFormGroup.get('attributes').get('booleanValue').value ? "value.true" : "value.false") | translate }}--> 279 +<!-- {{ (addEntityFormGroup.get('attributes.booleanValue').value ? "value.true" : "value.false") | translate }}-->
281 <!-- </mat-checkbox>--> 280 <!-- </mat-checkbox>-->
282 <!-- </div>--> 281 <!-- </div>-->
283 <!-- </div>--> 282 <!-- </div>-->
@@ -345,7 +344,6 @@ @@ -345,7 +344,6 @@
345 <!-- Create--> 344 <!-- Create-->
346 <!-- </button>--> 345 <!-- </button>-->
347 <!-- <button mat-button color="primary"--> 346 <!-- <button mat-button color="primary"-->
348 -<!-- style="margin-right: 20px;"-->  
349 <!-- type="button"--> 347 <!-- type="button"-->
350 <!-- [disabled]="(isLoading$ | async)"--> 348 <!-- [disabled]="(isLoading$ | async)"-->
351 <!-- (click)="cancel()" cdkFocusInitial>--> 349 <!-- (click)="cancel()" cdkFocusInitial>-->
@@ -186,28 +186,27 @@ @@ -186,28 +186,27 @@
186 // } 186 // }
187 // 187 //
188 // function getEntityInfo() { 188 // function getEntityInfo() {
189 -// entityService.getEntity(entityId.entityType, entityId.id).subscribe(function (entity) {  
190 -// vm.entity = entity;  
191 -// widgetContext.rxjs.forkJoin([  
192 -// entityRelationService.findInfoByFrom(entityId),  
193 -// entityRelationService.findInfoByTo(entityId),  
194 -// attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE')  
195 -// ]).subscribe(  
196 -// function (data) {  
197 -// getEntityRelations(data.slice(0,2));  
198 -// getEntityAttributes(data[2]);  
199 -// vm.editEntityFormGroup.patchValue({  
200 -// entityName: vm.entity.name,  
201 -// entityType: vm.entityType,  
202 -// entityLabel: vm.entity.label,  
203 -// type: vm.entity.type,  
204 -// attributes: vm.attributes,  
205 -// oldRelations: vm.oldRelationsData  
206 -// }, {emitEvent: false});  
207 -// }  
208 -// );  
209 -// });  
210 -// } 189 +// widgetContext.rxjs.forkJoin([
  190 +// entityRelationService.findInfoByFrom(entityId),
  191 +// entityRelationService.findInfoByTo(entityId),
  192 +// attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE'),
  193 +// entityService.getEntity(entityId.entityType, entityId.id)
  194 +// ]).subscribe(
  195 +// function (data) {
  196 +// getEntityRelations(data.slice(0,2));
  197 +// getEntityAttributes(data[2]);
  198 +// vm.entity = data[3];
  199 +// vm.editEntityFormGroup.patchValue({
  200 +// entityName: vm.entity.name,
  201 +// entityType: vm.entityType,
  202 +// entityLabel: vm.entity.label,
  203 +// type: vm.entity.type,
  204 +// attributes: vm.attributes,
  205 +// oldRelations: vm.oldRelationsData
  206 +// }, {emitEvent: false});
  207 +// }
  208 +// );
  209 +// }
211 // 210 //
212 // function saveEntity() { 211 // function saveEntity() {
213 // const formValues = vm.editEntityFormGroup.value; 212 // const formValues = vm.editEntityFormGroup.value;
@@ -218,9 +217,8 @@ @@ -218,9 +217,8 @@
218 // } else if (formValues.entityType == 'DEVICE') { 217 // } else if (formValues.entityType == 'DEVICE') {
219 // return deviceService.saveDevice(vm.entity); 218 // return deviceService.saveDevice(vm.entity);
220 // } 219 // }
221 -// } else {  
222 -// return widgetContext.rxjs.of([]);  
223 // } 220 // }
  221 +// return widgetContext.rxjs.of([]);
224 // } 222 // }
225 // 223 //
226 // function saveAttributes(entityId) { 224 // function saveAttributes(entityId) {
@@ -233,9 +231,8 @@ @@ -233,9 +231,8 @@
233 // } 231 // }
234 // if (attributesArray.length > 0) { 232 // if (attributesArray.length > 0) {
235 // return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray); 233 // return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray);
236 -// } else {  
237 -// return widgetContext.rxjs.of([]);  
238 // } 234 // }
  235 +// return widgetContext.rxjs.of([]);
239 // } 236 // }
240 // 237 //
241 // function saveRelations(entityId) { 238 // function saveRelations(entityId) {
@@ -270,9 +267,8 @@ @@ -270,9 +267,8 @@
270 // } 267 // }
271 // if (tasks.length > 0) { 268 // if (tasks.length > 0) {
272 // return widgetContext.rxjs.forkJoin(tasks); 269 // return widgetContext.rxjs.forkJoin(tasks);
273 -// } else {  
274 -// return widgetContext.rxjs.of([]);  
275 // } 270 // }
  271 +// return widgetContext.rxjs.of([]);
276 // } 272 // }
277 //} 273 //}
278 // 274 //
@@ -380,9 +376,8 @@ @@ -380,9 +376,8 @@
380 // } 376 // }
381 // if (attributesArray.length > 0) { 377 // if (attributesArray.length > 0) {
382 // return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray); 378 // return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray);
383 -// } else {  
384 -// return widgetContext.rxjs.of([]);  
385 // } 379 // }
  380 +// return widgetContext.rxjs.of([]);
386 // } 381 // }
387 // 382 //
388 // function saveRelations(entityId) { 383 // function saveRelations(entityId) {
@@ -404,8 +399,7 @@ @@ -404,8 +399,7 @@
404 // } 399 // }
405 // if (tasks.length > 0) { 400 // if (tasks.length > 0) {
406 // return widgetContext.rxjs.forkJoin(tasks); 401 // return widgetContext.rxjs.forkJoin(tasks);
407 -// } else {  
408 -// return widgetContext.rxjs.of([]);  
409 // } 402 // }
  403 +// return widgetContext.rxjs.of([]);
410 // } 404 // }
411 //} 405 //}