Skip to content

Commit f77baea

Browse files
committed
Adding changes to also delete entityItems which are no longer in the list.
Fixing the broken typescript files with the new SDK.
1 parent e928849 commit f77baea

File tree

10 files changed

+38
-24
lines changed

10 files changed

+38
-24
lines changed

eFormAPI/eFormAPI/Controllers/EntitySearchController.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public OperationResult CreateEntityGroup(AdvEntitySearchableGroupEditModel editM
5151
var nextItemUid = entityGroup.EntityGroupItemLst.Count;
5252
foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
5353
{
54-
core.EntitySearchItemCreate(entityGroup.Id.ToString(), entityItem.Name, entityItem.Description, nextItemUid.ToString());
54+
core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name, entityItem.Description, nextItemUid.ToString());
5555

5656
//entityGroup.EntityGroupItemLst.Add(new EntityItem(entityItem.Name,
5757
// entityItem.Description, nextItemUid.ToString(), Constants.WorkflowStates.Created));
@@ -82,20 +82,31 @@ public OperationResult UpdateEntityGroup(AdvEntitySearchableGroupEditModel editM
8282
{
8383
//var entityGroup = core.EntityGroupRead(groupCreate.MicrotingUUID);
8484
var nextItemUid = entityGroup.EntityGroupItemLst.Count;
85+
List<int> currentIds = new List<int>();
86+
8587
foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
8688
{
87-
if (entityItem.MicrotingUUID != null)
89+
if (string.IsNullOrEmpty(entityItem.MicrotingUUID))
8890
{
89-
core.EntityItemUpdate(entityItem.Id, entityItem.Name, entityItem.Description, entityItem.EntityItemUId, entityItem.DisplayIndex);
91+
EntityItem et = core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name, entityItem.Description, nextItemUid.ToString());
92+
currentIds.Add(et.Id);
9093
}
9194
else
9295
{
93-
core.EntitySearchItemCreate(entityGroup.Id.ToString(), entityItem.Name, entityItem.Description, nextItemUid.ToString());
96+
core.EntityItemUpdate(entityItem.Id, entityItem.Name, entityItem.Description, entityItem.EntityItemUId, entityItem.DisplayIndex);
97+
currentIds.Add(entityItem.Id);
9498
}
9599
//entityGroup.EntityGroupItemLst.Add(new EntityItem(entityItem.Name,
96100
// entityItem.Description, nextItemUid.ToString(), Constants.WorkflowStates.Created));
97101
nextItemUid++;
98102
}
103+
foreach (EntityItem entityItem in entityGroup.EntityGroupItemLst)
104+
{
105+
if (!currentIds.Contains(entityItem.Id))
106+
{
107+
core.EntityItemDelete(entityItem.Id);
108+
}
109+
}
99110
//core.EntityGroupUpdate(entityGroup);
100111
}
101112
return new OperationResult(true, LocaleHelper.GetString("ParamUpdatedSuccessfully", editModel.GroupUid));

eFormAPI/eFormAPI/Controllers/EntitySelectController.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public OperationResult CreateEntityGroup(AdvEntitySelectableGroupEditModel editM
5151
var nextItemUid = entityGroup.EntityGroupItemLst.Count;
5252
foreach (var entityItem in editModel.AdvEntitySelectableItemModels)
5353
{
54-
core.EntitySelectItemCreate(entityGroup.Id.ToString(), entityItem.Name, entityItem.DisplayIndex, nextItemUid.ToString());
54+
core.EntitySelectItemCreate(entityGroup.Id, entityItem.Name, entityItem.DisplayIndex, nextItemUid.ToString());
5555
//entityGroup.EntityGroupItemLst.Add(new EntityItem(entityItem.Name,
5656
// entityItem.Description, nextItemUid.ToString(), Constants.WorkflowStates.Created));
5757
nextItemUid++;
@@ -75,28 +75,31 @@ public OperationResult UpdateEntityGroup(AdvEntitySelectableGroupEditModel editM
7575
var core = _coreHelper.GetCore();
7676
var entityGroup = core.EntityGroupRead(editModel.GroupUid);
7777

78-
//entityGroup.EntityGroupItemLst = editModel.AdvEntitySelectableItemModels;
79-
//entityGroup.Name = editModel.Name;
80-
//core.EntityGroupUpdate(entityGroup);
8178
if (editModel.AdvEntitySelectableItemModels.Any())
8279
{
83-
//var entityGroup = core.EntityGroupRead(groupCreate.MicrotingUUID);
8480
var nextItemUid = entityGroup.EntityGroupItemLst.Count;
85-
foreach (var entityItem in editModel.AdvEntitySelectableItemModels)
81+
List<int> currentIds = new List<int>();
82+
foreach (EntityItem entityItem in editModel.AdvEntitySelectableItemModels)
8683
{
87-
if (entityItem.MicrotingUUID != null)
84+
if (string.IsNullOrEmpty(entityItem.MicrotingUUID))
8885
{
89-
core.EntityItemUpdate(entityItem.Id, entityItem.Name, entityItem.Description, entityItem.EntityItemUId, entityItem.DisplayIndex);
86+
EntityItem et = core.EntitySelectItemCreate(entityGroup.Id, entityItem.Name, entityItem.DisplayIndex, nextItemUid.ToString());
87+
currentIds.Add(et.Id);
9088
}
9189
else
9290
{
93-
core.EntitySelectItemCreate(entityGroup.Id.ToString(), entityItem.Name, entityItem.DisplayIndex, nextItemUid.ToString());
91+
core.EntityItemUpdate(entityItem.Id, entityItem.Name, entityItem.Description, entityItem.EntityItemUId, entityItem.DisplayIndex);
92+
currentIds.Add(entityItem.Id);
9493
}
95-
//entityGroup.EntityGroupItemLst.Add(new EntityItem(entityItem.Name,
96-
// entityItem.Description, nextItemUid.ToString(), Constants.WorkflowStates.Created));
9794
nextItemUid++;
9895
}
99-
//core.EntityGroupUpdate(entityGroup);
96+
foreach (EntityItem entityItem in entityGroup.EntityGroupItemLst)
97+
{
98+
if (!currentIds.Contains(entityItem.Id))
99+
{
100+
core.EntityItemDelete(entityItem.Id);
101+
}
102+
}
100103
}
101104
return new OperationResult(true, LocaleHelper.GetString("ParamUpdatedSuccessfully", editModel.GroupUid));
102105
}

eform-client/src/app/common/models/advanced/adv-entity-searchable-group.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {AdvEntitySearchableItemModel} from './adv-entity-searchable-item.model';
22
export class AdvEntitySearchableGroupModel {
33
name: string;
44
type: string;
5-
entityGroupMUId: string;
5+
microtingUUID: string;
66
workflowState: string;
77
status = true;
88
createdAt: Date;

eform-client/src/app/common/models/advanced/adv-entity-selectable-group.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {AdvEntitySelectableItemModel} from './adv-entity-selectable-item.model';
22
export class AdvEntitySelectableGroupModel {
33
name: string;
44
type: string;
5-
entityGroupMUId: string;
5+
microtingUUID: string;
66
workflowState: string;
77
status = true;
88
createdAt: Date;

eform-client/src/app/modules/advanced/components/entity-search/entity-search-remove/entity-search-remove.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class EntitySearchRemoveComponent implements OnInit {
2424

2525
deleteSelectedAdvEntitySearchableGroup() {
2626
this.spinnerStatus = true;
27-
this.entitySearchService.deleteEntitySearchableGroup(this.selectedGroupModel.entityGroupMUId).subscribe((data) => {
27+
this.entitySearchService.deleteEntitySearchableGroup(this.selectedGroupModel.microtingUUID).subscribe((data) => {
2828
if (data && data.success) {
2929
this.frame.hide();
3030
this.onEntityRemoved.emit();

eform-client/src/app/modules/advanced/components/entity-search/entity-search/entity-search.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</thead>
5353
<tbody>
5454
<tr *ngFor="let advEntitySearchableGroup of advEntitySearchableGroupListModel.entityGroups">
55-
<td scope="row">{{advEntitySearchableGroup.entityGroupMUId}}</td>
55+
<td scope="row">{{advEntitySearchableGroup.microtingUUID}}</td>
5656
<td> {{advEntitySearchableGroup.name}}</td>
5757
<td>
5858
<div class="d-flex flex-row justify-content-center">

eform-client/src/app/modules/advanced/components/entity-search/entity-search/entity-search.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class EntitySearchComponent implements OnInit {
4242

4343
openModalSearchEdit(selectedSearchModel: AdvEntitySelectableGroupModel) {
4444
this.selectedAdvGroup = selectedSearchModel;
45-
this.modalSearchEdit.show(this.selectedAdvGroup.entityGroupMUId);
45+
this.modalSearchEdit.show(this.selectedAdvGroup.microtingUUID);
4646
}
4747

4848

eform-client/src/app/modules/advanced/components/entity-select/entity-select-remove/entity-select-remove.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class EntitySelectRemoveComponent implements OnInit {
2424

2525
deleteSelectedAdvEntitySelectableGroup() {
2626
this.spinnerStatus = true;
27-
this.entitySelectService.deleteEntitySelectableGroup(this.selectedGroupModel.entityGroupMUId).subscribe((data) => {
27+
this.entitySelectService.deleteEntitySelectableGroup(this.selectedGroupModel.microtingUUID).subscribe((data) => {
2828
if (data && data.success) {
2929
this.frame.hide();
3030
this.onEntityRemoved.emit();

eform-client/src/app/modules/advanced/components/entity-select/entity-select/entity-select.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</thead>
5353
<tbody>
5454
<tr *ngFor="let advEntitySelectableGroup of advEntitySelectableGroupListModel.entityGroups">
55-
<td scope="row">{{advEntitySelectableGroup.entityGroupMUId}}</td>
55+
<td scope="row">{{advEntitySelectableGroup.microtingUUID}}</td>
5656
<td> {{advEntitySelectableGroup.name}}</td>
5757
<td>
5858
<div class="d-flex flex-row justify-content-center">

eform-client/src/app/modules/advanced/components/entity-select/entity-select/entity-select.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class EntitySelectComponent implements OnInit {
4242

4343
openModalSelectEdit(selectedSelectModel: AdvEntitySelectableGroupModel) {
4444
this.selectedAdvGroup = selectedSelectModel;
45-
this.modalSelectEdit.show(this.selectedAdvGroup.entityGroupMUId);
45+
this.modalSelectEdit.show(this.selectedAdvGroup.microtingUUID);
4646
}
4747

4848

0 commit comments

Comments
 (0)