2019-10-24 19:52:19 +03:00
|
|
|
/*=======================================================================*/
|
|
|
|
|
/*===== There are three examples: for delete, edit and add entity =====*/
|
|
|
|
|
/*=======================================================================*/
|
|
|
|
|
/*======================= Delete entity example =======================*/
|
|
|
|
|
/*=======================================================================*/
|
|
|
|
|
//
|
2020-03-26 14:50:23 +02:00
|
|
|
//let $injector = widgetContext.$scope.$injector;
|
|
|
|
|
//let dialogs = $injector.get(widgetContext.servicesMap.get('dialogs'));
|
|
|
|
|
//let assetService = $injector.get(widgetContext.servicesMap.get('assetService'));
|
|
|
|
|
//let deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));
|
2019-10-24 19:52:19 +03:00
|
|
|
//
|
|
|
|
|
//openDeleteEntityDialog();
|
|
|
|
|
//
|
|
|
|
|
//function openDeleteEntityDialog() {
|
2020-03-26 14:50:23 +02:00
|
|
|
// let title = 'Delete ' + entityId.entityType.toLowerCase() + ' ' +
|
|
|
|
|
// entityName;
|
|
|
|
|
// let content = 'Are you sure you want to delete the ' +
|
|
|
|
|
// entityId.entityType.toLowerCase() + ' ' + entityName + '?';
|
|
|
|
|
// dialogs.confirm(title, content, 'Cancel', 'Delete').subscribe(
|
|
|
|
|
// function(result) {
|
|
|
|
|
// if (result) {
|
|
|
|
|
// deleteEntity();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// );
|
2019-10-24 19:52:19 +03:00
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//function deleteEntity() {
|
2020-03-26 14:50:23 +02:00
|
|
|
// deleteEntityObservable(entityId).subscribe(
|
2019-10-24 19:52:19 +03:00
|
|
|
// function success() {
|
2020-03-26 14:50:23 +02:00
|
|
|
// widgetContext.updateAliases();
|
2019-10-24 19:52:19 +03:00
|
|
|
// },
|
|
|
|
|
// function fail() {
|
|
|
|
|
// showErrorDialog();
|
|
|
|
|
// }
|
|
|
|
|
// );
|
|
|
|
|
//}
|
|
|
|
|
//
|
2020-03-26 14:50:23 +02:00
|
|
|
//function deleteEntityObservable(entityId) {
|
|
|
|
|
// if (entityId.entityType == "ASSET") {
|
2019-10-24 19:52:19 +03:00
|
|
|
// return assetService.deleteAsset(entityId.id);
|
2020-03-26 14:50:23 +02:00
|
|
|
// } else if (entityId.entityType == "DEVICE") {
|
2019-10-24 19:52:19 +03:00
|
|
|
// return deviceService.deleteDevice(entityId.id);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//function showErrorDialog() {
|
2020-03-26 14:50:23 +02:00
|
|
|
// let title = 'Error';
|
|
|
|
|
// let content = 'An error occurred while deleting the entity. Please try again.';
|
|
|
|
|
// dialogs.alert(title, content, 'CLOSE').subscribe(
|
|
|
|
|
// function(result) {}
|
|
|
|
|
// );
|
2019-10-24 19:52:19 +03:00
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
/*=======================================================================*/
|
|
|
|
|
/*======================== Edit entity example ========================*/
|
|
|
|
|
/*=======================================================================*/
|
|
|
|
|
//
|
2020-03-26 14:50:23 +02:00
|
|
|
//let $injector = widgetContext.$scope.$injector;
|
|
|
|
|
//let customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));
|
|
|
|
|
//let entityService = $injector.get(widgetContext.servicesMap.get('entityService'));
|
|
|
|
|
//let assetService = $injector.get(widgetContext.servicesMap.get('assetService'));
|
|
|
|
|
//let deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));
|
|
|
|
|
//let attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));
|
|
|
|
|
//let entityRelationService = $injector.get(widgetContext.servicesMap.get('entityRelationService'));
|
2019-10-24 19:52:19 +03:00
|
|
|
//
|
|
|
|
|
//openEditEntityDialog();
|
|
|
|
|
//
|
|
|
|
|
//function openEditEntityDialog() {
|
2020-03-26 14:50:23 +02:00
|
|
|
// customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();
|
2019-10-24 19:52:19 +03:00
|
|
|
//}
|
|
|
|
|
//
|
2020-03-26 14:50:23 +02:00
|
|
|
//function EditEntityDialogController(instance) {
|
|
|
|
|
// let vm = instance;
|
|
|
|
|
//
|
2019-10-24 19:52:19 +03:00
|
|
|
// vm.entityName = entityName;
|
|
|
|
|
// vm.entityType = entityId.entityType;
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.entitySearchDirection = {
|
|
|
|
|
// from: "FROM",
|
|
|
|
|
// to: "TO"
|
|
|
|
|
// };
|
2019-10-24 19:52:19 +03:00
|
|
|
// vm.attributes = {};
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.oldRelationsData = [];
|
2019-10-24 19:52:19 +03:00
|
|
|
// vm.relationsToDelete = [];
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.entity = {};
|
|
|
|
|
//
|
|
|
|
|
// vm.editEntityFormGroup = vm.fb.group({
|
|
|
|
|
// entityName: ['', [vm.validators.required]],
|
|
|
|
|
// entityType: [null],
|
|
|
|
|
// entityLabel: [null],
|
|
|
|
|
// type: ['', [vm.validators.required]],
|
|
|
|
|
// attributes: vm.fb.group({
|
|
|
|
|
// latitude: [null],
|
|
|
|
|
// longitude: [null],
|
|
|
|
|
// address: [null],
|
|
|
|
|
// owner: [null],
|
|
|
|
|
// number: [null, [vm.validators.pattern(/^-?[0-9]+$/)]],
|
|
|
|
|
// booleanValue: [false]
|
|
|
|
|
// }),
|
|
|
|
|
// oldRelations: vm.fb.array([]),
|
|
|
|
|
// relations: vm.fb.array([])
|
|
|
|
|
// });
|
|
|
|
|
//
|
2019-10-24 19:52:19 +03:00
|
|
|
// getEntityInfo();
|
|
|
|
|
//
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.cancel = function() {
|
|
|
|
|
// vm.dialogRef.close(null);
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// vm.relations = function() {
|
|
|
|
|
// return vm.editEntityFormGroup.get('relations');
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// vm.oldRelations = function() {
|
|
|
|
|
// return vm.editEntityFormGroup.get('oldRelations');
|
|
|
|
|
// };
|
|
|
|
|
//
|
2019-10-24 19:52:19 +03:00
|
|
|
// vm.addRelation = function() {
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.relations().push(vm.fb.group({
|
|
|
|
|
// relatedEntity: [null, [vm.validators.required]],
|
|
|
|
|
// relationType: [null, [vm.validators.required]],
|
|
|
|
|
// direction: [null, [vm.validators.required]]
|
|
|
|
|
// }));
|
2019-10-24 19:52:19 +03:00
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
//
|
|
|
|
|
// function addOldRelation() {
|
|
|
|
|
// vm.oldRelations().push(vm.fb.group({
|
|
|
|
|
// relatedEntity: [{value: null, disabled: true}, [vm.validators.required]],
|
|
|
|
|
// relationType: [{value: null, disabled: true}, [vm.validators.required]],
|
|
|
|
|
// direction: [{value: null, disabled: true}, [vm.validators.required]]
|
|
|
|
|
// }));
|
|
|
|
|
// }
|
|
|
|
|
//
|
2019-10-24 19:52:19 +03:00
|
|
|
// vm.removeRelation = function(index) {
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.relations().removeAt(index);
|
|
|
|
|
// vm.relations().markAsDirty();
|
2019-10-24 19:52:19 +03:00
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
//
|
2023-05-01 16:57:56 +03:00
|
|
|
// vm.removeOldRelation = function(index, relation) {
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.oldRelations().removeAt(index);
|
2023-05-01 16:57:56 +03:00
|
|
|
// vm.relationsToDelete.push(relation);
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.oldRelations().markAsDirty();
|
2019-10-24 19:52:19 +03:00
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
//
|
2019-10-24 19:52:19 +03:00
|
|
|
// vm.save = function() {
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.editEntityFormGroup.markAsPristine();
|
|
|
|
|
// widgetContext.rxjs.forkJoin([
|
|
|
|
|
// saveAttributes(entityId),
|
|
|
|
|
// saveRelations(entityId),
|
|
|
|
|
// saveEntity()
|
|
|
|
|
// ]).subscribe(
|
|
|
|
|
// function () {
|
|
|
|
|
// widgetContext.updateAliases();
|
|
|
|
|
// vm.dialogRef.close(null);
|
|
|
|
|
// }
|
|
|
|
|
// );
|
2019-10-24 19:52:19 +03:00
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// function getEntityAttributes(attributes) {
|
|
|
|
|
// for (var i = 0; i < attributes.length; i++) {
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.attributes[attributes[i].key] = attributes[i].value;
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// function getEntityRelations(relations) {
|
2020-03-26 14:50:23 +02:00
|
|
|
// let relationsFrom = relations[0];
|
|
|
|
|
// let relationsTo = relations[1];
|
|
|
|
|
// for (let i=0; i < relationsFrom.length; i++) {
|
|
|
|
|
// let relation = {
|
|
|
|
|
// direction: 'FROM',
|
2019-10-24 19:52:19 +03:00
|
|
|
// relationType: relationsFrom[i].type,
|
|
|
|
|
// relatedEntity: relationsFrom[i].to
|
|
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.oldRelationsData.push(relation);
|
|
|
|
|
// addOldRelation();
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
2020-03-26 14:50:23 +02:00
|
|
|
// for (let i=0; i < relationsTo.length; i++) {
|
|
|
|
|
// let relation = {
|
|
|
|
|
// direction: 'TO',
|
2019-10-24 19:52:19 +03:00
|
|
|
// relationType: relationsTo[i].type,
|
|
|
|
|
// relatedEntity: relationsTo[i].from
|
|
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.oldRelationsData.push(relation);
|
|
|
|
|
// addOldRelation();
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// function getEntityInfo() {
|
2020-06-11 10:00:37 +03:00
|
|
|
// widgetContext.rxjs.forkJoin([
|
|
|
|
|
// entityRelationService.findInfoByFrom(entityId),
|
|
|
|
|
// entityRelationService.findInfoByTo(entityId),
|
|
|
|
|
// attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE'),
|
|
|
|
|
// entityService.getEntity(entityId.entityType, entityId.id)
|
|
|
|
|
// ]).subscribe(
|
|
|
|
|
// function (data) {
|
|
|
|
|
// getEntityRelations(data.slice(0,2));
|
|
|
|
|
// getEntityAttributes(data[2]);
|
|
|
|
|
// vm.entity = data[3];
|
|
|
|
|
// vm.editEntityFormGroup.patchValue({
|
|
|
|
|
// entityName: vm.entity.name,
|
|
|
|
|
// entityType: vm.entityType,
|
|
|
|
|
// entityLabel: vm.entity.label,
|
|
|
|
|
// type: vm.entity.type,
|
|
|
|
|
// attributes: vm.attributes,
|
|
|
|
|
// oldRelations: vm.oldRelationsData
|
|
|
|
|
// }, {emitEvent: false});
|
|
|
|
|
// }
|
|
|
|
|
// );
|
|
|
|
|
// }
|
2019-10-24 19:52:19 +03:00
|
|
|
//
|
2020-03-26 14:50:23 +02:00
|
|
|
// function saveEntity() {
|
|
|
|
|
// const formValues = vm.editEntityFormGroup.value;
|
|
|
|
|
// if (vm.entity.label !== formValues.entityLabel){
|
|
|
|
|
// vm.entity.label = formValues.entityLabel;
|
|
|
|
|
// if (formValues.entityType == 'ASSET') {
|
|
|
|
|
// return assetService.saveAsset(vm.entity);
|
|
|
|
|
// } else if (formValues.entityType == 'DEVICE') {
|
|
|
|
|
// return deviceService.saveDevice(vm.entity);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2020-06-11 10:00:37 +03:00
|
|
|
// return widgetContext.rxjs.of([]);
|
2020-03-26 14:50:23 +02:00
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// function saveAttributes(entityId) {
|
|
|
|
|
// let attributes = vm.editEntityFormGroup.get('attributes').value;
|
|
|
|
|
// let attributesArray = [];
|
|
|
|
|
// for (let key in attributes) {
|
|
|
|
|
// if (attributes[key] !== vm.attributes[key]) {
|
|
|
|
|
// attributesArray.push({key: key, value: attributes[key]});
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (attributesArray.length > 0) {
|
2020-03-26 14:50:23 +02:00
|
|
|
// return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray);
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
2020-06-11 10:00:37 +03:00
|
|
|
// return widgetContext.rxjs.of([]);
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
//
|
2020-03-26 14:50:23 +02:00
|
|
|
// function saveRelations(entityId) {
|
|
|
|
|
// let relations = vm.editEntityFormGroup.get('relations').value;
|
|
|
|
|
// let tasks = [];
|
|
|
|
|
// for(let i=0; i < relations.length; i++) {
|
|
|
|
|
// let relation = {
|
|
|
|
|
// type: relations[i].relationType,
|
|
|
|
|
// typeGroup: 'COMMON'
|
2019-10-24 19:52:19 +03:00
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
// if (relations[i].direction == 'FROM') {
|
|
|
|
|
// relation.to = relations[i].relatedEntity;
|
2019-10-24 19:52:19 +03:00
|
|
|
// relation.from = entityId;
|
|
|
|
|
// } else {
|
|
|
|
|
// relation.to = entityId;
|
2020-03-26 14:50:23 +02:00
|
|
|
// relation.from = relations[i].relatedEntity;
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
// tasks.push(entityRelationService.saveRelation(relation));
|
|
|
|
|
// }
|
2020-03-26 14:50:23 +02:00
|
|
|
// for (let i=0; i < vm.relationsToDelete.length; i++) {
|
|
|
|
|
// let relation = {
|
2019-10-24 19:52:19 +03:00
|
|
|
// type: vm.relationsToDelete[i].relationType
|
|
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
// if (vm.relationsToDelete[i].direction == 'FROM') {
|
2019-10-24 19:52:19 +03:00
|
|
|
// relation.to = vm.relationsToDelete[i].relatedEntity;
|
|
|
|
|
// relation.from = entityId;
|
|
|
|
|
// } else {
|
|
|
|
|
// relation.to = entityId;
|
|
|
|
|
// relation.from = vm.relationsToDelete[i].relatedEntity;
|
|
|
|
|
// }
|
2020-03-26 14:50:23 +02:00
|
|
|
// tasks.push(entityRelationService.deleteRelation(relation.from, relation.type, relation.to));
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
2020-03-26 14:50:23 +02:00
|
|
|
// if (tasks.length > 0) {
|
|
|
|
|
// return widgetContext.rxjs.forkJoin(tasks);
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
2020-06-11 10:00:37 +03:00
|
|
|
// return widgetContext.rxjs.of([]);
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
/*========================================================================*/
|
|
|
|
|
/*========================= Add entity example =========================*/
|
|
|
|
|
/*========================================================================*/
|
|
|
|
|
//
|
2020-03-26 14:50:23 +02:00
|
|
|
//let $injector = widgetContext.$scope.$injector;
|
|
|
|
|
//let customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));
|
|
|
|
|
//let assetService = $injector.get(widgetContext.servicesMap.get('assetService'));
|
|
|
|
|
//let deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));
|
|
|
|
|
//let attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));
|
|
|
|
|
//let entityRelationService = $injector.get(widgetContext.servicesMap.get('entityRelationService'));
|
2019-10-24 19:52:19 +03:00
|
|
|
//
|
|
|
|
|
//openAddEntityDialog();
|
|
|
|
|
//
|
|
|
|
|
//function openAddEntityDialog() {
|
2020-03-26 14:50:23 +02:00
|
|
|
// customDialog.customDialog(htmlTemplate, AddEntityDialogController).subscribe();
|
2019-10-24 19:52:19 +03:00
|
|
|
//}
|
|
|
|
|
//
|
2020-03-26 14:50:23 +02:00
|
|
|
//function AddEntityDialogController(instance) {
|
|
|
|
|
// let vm = instance;
|
|
|
|
|
//
|
|
|
|
|
// vm.allowedEntityTypes = ['ASSET', 'DEVICE'];
|
|
|
|
|
// vm.entitySearchDirection = {
|
|
|
|
|
// from: "FROM",
|
|
|
|
|
// to: "TO"
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// vm.addEntityFormGroup = vm.fb.group({
|
|
|
|
|
// entityName: ['', [vm.validators.required]],
|
|
|
|
|
// entityType: ['DEVICE'],
|
|
|
|
|
// entityLabel: [null],
|
|
|
|
|
// type: ['', [vm.validators.required]],
|
|
|
|
|
// attributes: vm.fb.group({
|
|
|
|
|
// latitude: [null],
|
|
|
|
|
// longitude: [null],
|
|
|
|
|
// address: [null],
|
|
|
|
|
// owner: [null],
|
|
|
|
|
// number: [null, [vm.validators.pattern(/^-?[0-9]+$/)]],
|
|
|
|
|
// booleanValue: [null]
|
|
|
|
|
// }),
|
|
|
|
|
// relations: vm.fb.array([])
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// vm.cancel = function() {
|
|
|
|
|
// vm.dialogRef.close(null);
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// vm.relations = function() {
|
|
|
|
|
// return vm.addEntityFormGroup.get('relations');
|
|
|
|
|
// };
|
2019-10-24 19:52:19 +03:00
|
|
|
//
|
|
|
|
|
// vm.addRelation = function() {
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.relations().push(vm.fb.group({
|
|
|
|
|
// relatedEntity: [null, [vm.validators.required]],
|
|
|
|
|
// relationType: [null, [vm.validators.required]],
|
|
|
|
|
// direction: [null, [vm.validators.required]]
|
|
|
|
|
// }));
|
2019-10-24 19:52:19 +03:00
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
//
|
2019-10-24 19:52:19 +03:00
|
|
|
// vm.removeRelation = function(index) {
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.relations().removeAt(index);
|
|
|
|
|
// vm.relations().markAsDirty();
|
2019-10-24 19:52:19 +03:00
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
//
|
2019-10-24 19:52:19 +03:00
|
|
|
// vm.save = function() {
|
2020-03-26 14:50:23 +02:00
|
|
|
// vm.addEntityFormGroup.markAsPristine();
|
|
|
|
|
// saveEntityObservable().subscribe(
|
2019-10-24 19:52:19 +03:00
|
|
|
// function (entity) {
|
2020-03-26 14:50:23 +02:00
|
|
|
// widgetContext.rxjs.forkJoin([
|
|
|
|
|
// saveAttributes(entity.id),
|
|
|
|
|
// saveRelations(entity.id)
|
|
|
|
|
// ]).subscribe(
|
|
|
|
|
// function () {
|
|
|
|
|
// widgetContext.updateAliases();
|
|
|
|
|
// vm.dialogRef.close(null);
|
|
|
|
|
// }
|
|
|
|
|
// );
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
// );
|
|
|
|
|
// };
|
|
|
|
|
//
|
2020-03-26 14:50:23 +02:00
|
|
|
// function saveEntityObservable() {
|
|
|
|
|
// const formValues = vm.addEntityFormGroup.value;
|
|
|
|
|
// let entity = {
|
|
|
|
|
// name: formValues.entityName,
|
|
|
|
|
// type: formValues.type,
|
|
|
|
|
// label: formValues.entityLabel
|
2019-10-24 19:52:19 +03:00
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
// if (formValues.entityType == 'ASSET') {
|
2019-10-24 19:52:19 +03:00
|
|
|
// return assetService.saveAsset(entity);
|
2020-03-26 14:50:23 +02:00
|
|
|
// } else if (formValues.entityType == 'DEVICE') {
|
2019-10-24 19:52:19 +03:00
|
|
|
// return deviceService.saveDevice(entity);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// function saveAttributes(entityId) {
|
2020-03-26 14:50:23 +02:00
|
|
|
// let attributes = vm.addEntityFormGroup.get('attributes').value;
|
|
|
|
|
// let attributesArray = [];
|
|
|
|
|
// for (let key in attributes) {
|
|
|
|
|
// if(attributes[key] !== null) {
|
|
|
|
|
// attributesArray.push({key: key, value: attributes[key]});
|
|
|
|
|
// }
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
// if (attributesArray.length > 0) {
|
2020-03-26 14:50:23 +02:00
|
|
|
// return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray);
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
2020-06-11 10:00:37 +03:00
|
|
|
// return widgetContext.rxjs.of([]);
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// function saveRelations(entityId) {
|
2020-03-26 14:50:23 +02:00
|
|
|
// let relations = vm.addEntityFormGroup.get('relations').value;
|
|
|
|
|
// let tasks = [];
|
|
|
|
|
// for(let i=0; i < relations.length; i++) {
|
|
|
|
|
// let relation = {
|
|
|
|
|
// type: relations[i].relationType,
|
|
|
|
|
// typeGroup: 'COMMON'
|
2019-10-24 19:52:19 +03:00
|
|
|
// };
|
2020-03-26 14:50:23 +02:00
|
|
|
// if (relations[i].direction == 'FROM') {
|
|
|
|
|
// relation.to = relations[i].relatedEntity;
|
2019-10-24 19:52:19 +03:00
|
|
|
// relation.from = entityId;
|
|
|
|
|
// } else {
|
|
|
|
|
// relation.to = entityId;
|
2020-03-26 14:50:23 +02:00
|
|
|
// relation.from = relations[i].relatedEntity;
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
// tasks.push(entityRelationService.saveRelation(relation));
|
|
|
|
|
// }
|
2020-03-26 14:50:23 +02:00
|
|
|
// if (tasks.length > 0) {
|
|
|
|
|
// return widgetContext.rxjs.forkJoin(tasks);
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
2020-06-11 10:00:37 +03:00
|
|
|
// return widgetContext.rxjs.of([]);
|
2019-10-24 19:52:19 +03:00
|
|
|
// }
|
|
|
|
|
//}
|