Skip to content

Commit

Permalink
ref #850 Added move users to group feature
Browse files Browse the repository at this point in the history
  • Loading branch information
damiennicolleau committed Mar 3, 2025
1 parent e3f659b commit 79ae301
Show file tree
Hide file tree
Showing 4 changed files with 448 additions and 112 deletions.
180 changes: 151 additions & 29 deletions _c8oProject/mobilePages/adminDashboardUsersWithinGroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ scriptContent:
'/*Begin_c8o_PageImport*/
import { C8Oforms_AddUserToGroupForm } from ''../../components/c8oforms.addusertogroupform/c8oforms-addusertogroupform'';
import { C8Oforms_AddGroupForm } from ''../../components/c8oforms.addgroupform/c8oforms-addgroupform'';
import { C8Oforms_MoveUserToGroupForm } from ''../../components/c8oforms.moveusertogroupform/c8oforms-moveusertogroupform''
/*End_c8o_PageImport*/
/*Begin_c8o_PageDeclaration*/
public alertController: AlertController;
Expand Down Expand Up @@ -190,6 +191,7 @@ scriptContent:
return;
}
else if(bulkOperation == "deleteUsersGroup"){
console.log(docs)
for(let i = 0; i < docs.length;i++) {
args = {meta: JSON.stringify(docs[i])};
sequence = "C8Oforms.admin_user_delete_from_group";
Expand All @@ -202,6 +204,8 @@ scriptContent:
await this.presentToast(this.translate.instant(errorMsg), ''toastError'');
}
}
// console.log(this.local.data);
return;
}
else if(bulkOperation == "updateUsersGroup") {
sequence = "C8Oforms.admin_users_move_in_group";
Expand Down Expand Up @@ -267,7 +271,7 @@ scriptContent:
}
async showModal(grid = "userToGroup"){
const modal = await this.modalController.create({
component: (grid == "userToGroup") ? C8Oforms_AddUserToGroupForm : C8Oforms_AddGroupForm,
component: (grid == "userToGroup") ? C8Oforms_AddUserToGroupForm : ((grid == ''moveUserToGroup'') ? C8Oforms_MoveUserToGroupForm : C8Oforms_AddGroupForm),
cssClass: "modalAddGroup"
});
Expand Down Expand Up @@ -1333,32 +1337,54 @@ title: Title for adminDashboardUsersWithinGroups
attrName: (RowClicked)
comment: Fired when a row is clicked. Data will be the agGrid event
eventName: RowClicked
↓CustomAsyncAction [ngx.components.UICustomAsyncAction-1740565225527]:
actionValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.FormatedContent
- com.twinsoft.convertigo.beans.common.FormatedContent:
: |
' try {
// console.log(event);
// if (event?.data?.group.indexOf(page.translate.instant("all_users")) != -1) {
// page.local.data.result.childrenLabels[2].hide = false;
// } else {
// page.local.data.result.childrenLabels[2].hide = true;
// }
console.log(event.data);
page.valuesSelected = event?.data?.children;
page.groupSelected = event?.data?.group;
page.global.groupSelected = event?.data?.group;
page.local.selected2 = page.myaggrid2?.agGrid?.api?.getSelectedNodes({ startRow: 0, endRow: 1 }).length > 0;
page.global.selectedUsers = page.myaggrid2?.agGrid?.api?.getSelectedNodes();
page.ref.detectChanges();
} catch (e) {
} finally {
return;
}
'
↓CallSequence [ngx.components.UIDynamicAction-1741002738792]:
beanData: '{"ionBean":"CallSequenceAction","requestable":"plain:C8Oforms.admin_users_of_group_get"}'
↓group [ngx.components.UIControlVariable-1741002762144]:
comment: new variable
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: 'source:{"filter":"Action","project":"C8Oforms","input":"","model":{"data":[{"priority":1740488756848,"rootEvent":true,"pageLocals":false}],"path":"?.out","prefix":"(stack[''root'']?.out?.data?.group != this.translate.instant(''any_group'')) ? ","suffix":"?.data?.group : ''any_group''","custom":"","useCustom":false}}'
↓_use_key [ngx.components.UIControlVariable-1741007450883]:
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: plain:group
↓CustomAsyncAction [ngx.components.UICustomAsyncAction-1740565225527]:
actionValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.FormatedContent
- com.twinsoft.convertigo.beans.common.FormatedContent:
: |
' try {
// console.log(event);
// if (event?.data?.group.indexOf(page.translate.instant("all_users")) != -1) {
// page.local.data.result.childrenLabels[2].hide = false;
// } else {
// page.local.data.result.childrenLabels[2].hide = true;
// }
// console.log(vars);
if (page.translate.instant(''all_users'') != event?.data?.group) {
page.valuesSelected = vars.children.users;
} else {
page.valuesSelected = event?.data?.children;
}
page.groupSelected = event?.data?.group;
page.global.groupSelected = event?.data?.group;
page.local.selected2 = page.myaggrid2?.agGrid?.api?.getSelectedNodes({ startRow: 0, endRow: 1 }).length > 0;
page.global.selectedUsers = page.myaggrid2?.agGrid?.api?.getSelectedNodes();
page.ref.detectChanges();
} catch (e) {
} finally {
return;
}
'
↓children [ngx.components.UIControlVariable-1741002827074]:
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: source:{"filter":"Action","project":"C8Oforms","input":"","model":{"data":[{"priority":1741002738792,"rootEvent":false,"pageLocals":false},{"priority":1740488756848,"rootEvent":true,"pageLocals":false}],"path":"?.out?.object","prefix":"","suffix":"","custom":"","useCustom":false}}
↓Event2 [ngx.components.UIControlEvent-1740488756851]:
attrName: (RowSelected)
comment: Fired when a row is selected. Data will be the agGrid event
Expand Down Expand Up @@ -1924,8 +1950,44 @@ title: Title for adminDashboardUsersWithinGroups
- ↑classname: com.twinsoft.convertigo.beans.common.FormatedContent
- com.twinsoft.convertigo.beans.common.FormatedContent:
: |
page.performBulk("deleteUsersGroup", "group_sure_delete_rows","group_delete_row_confirm", "group_delete_row_error", "cancel_pwamsg", "Supprimer");
page.performBulk("deleteUsersGroup", "group_sure_delete_rows","group_delete_row_confirm", "group_delete_row_error", "cancel_pwamsg", "Supprimer");
↓CallSequence [ngx.components.UIDynamicAction-1741022313954]:
beanData: '{"ionBean":"CallSequenceAction","requestable":"plain:C8Oforms.admin_users_of_group_get"}'
↓group [ngx.components.UIControlVariable-1741022313957]:
comment: new variable
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: script:this.groupSelected
↓_use_key [ngx.components.UIControlVariable-1741022313960]:
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: plain:group
↓CustomAsyncAction [ngx.components.UICustomAsyncAction-1741022313963]:
actionValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.FormatedContent
- com.twinsoft.convertigo.beans.common.FormatedContent:
: |
' try {
console.log(vars.children.users);
page.valuesSelected = vars.children.users;
page.local.selected2 = page.myaggrid2?.agGrid?.api?.getSelectedNodes({ startRow: 0, endRow: 1 }).length > 0;
page.global.selectedUsers = page.myaggrid2?.agGrid?.api?.getSelectedNodes();
page.ref.detectChanges();
} catch (e) {
} finally {
return;
}
'
↓children [ngx.components.UIControlVariable-1741022313966]:
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: source:{"filter":"Action","project":"C8Oforms","input":"","model":{"data":[{"priority":1741022313954,"rootEvent":false,"pageLocals":false},{"priority":1740592291284,"rootEvent":true,"pageLocals":false},{"priority":1740592291287,"rootEvent":false,"pageLocals":false}],"path":"?.out?.object","prefix":"","suffix":"","custom":"","useCustom":false}}
↓ButtonMoveUsersGroup [ngx.components.UIDynamicElement-1740592291290]:
beanData: |
'{
Expand Down Expand Up @@ -1962,6 +2024,65 @@ title: Title for adminDashboardUsersWithinGroups
page.performBulk("delete", "sure_delete_rows","delete_row_confirm", "delete_row_error", "cancel_pwamsg", "Supprimer");
isEnabled: false
↓showModalMoveUserToGroup [ngx.components.UICustomAsyncAction-1741024254719]:
actionValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.FormatedContent
- com.twinsoft.convertigo.beans.common.FormatedContent:
: |
try {
page.showModal("moveUserToGroup");
} catch (e) {
console.error("error showing addUser", e);
} finally {
return;
}
↓CallSequence [ngx.components.UIDynamicAction-1741024566170]:
beanData: '{"ionBean":"CallSequenceAction","requestable":"plain:C8Oforms.admin_users_of_group_get"}'
isEnabled: false
↓group [ngx.components.UIControlVariable-1741024566173]:
comment: new variable
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: script:this.groupSelected
↓_use_key [ngx.components.UIControlVariable-1741024566176]:
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: plain:group
↓CustomAsyncAction [ngx.components.UICustomAsyncAction-1741024566179]:
actionValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.FormatedContent
- com.twinsoft.convertigo.beans.common.FormatedContent:
: |
' try {
console.log(vars.children.users);
page.valuesSelected = vars.children.users;
page.local.selected2 = page.myaggrid2?.agGrid?.api?.getSelectedNodes({ startRow: 0, endRow: 1 }).length > 0;
page.global.selectedUsers = page.myaggrid2?.agGrid?.api?.getSelectedNodes();
page.ref.detectChanges();
} catch (e) {
} finally {
return;
}
'
↓children [ngx.components.UIControlVariable-1741024566182]:
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: source:{"filter":"Action","project":"C8Oforms","input":"","model":{"data":[{"priority":1741024566170,"rootEvent":false,"pageLocals":false},{"priority":1740592291284,"rootEvent":true,"pageLocals":false},{"priority":1740592291287,"rootEvent":false,"pageLocals":false}],"path":"?.out?.object","prefix":"","suffix":"","custom":"","useCustom":false}}
↓loadGridData [ngx.components.UICustomAsyncAction-1741024566185]:
actionValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.FormatedContent
- com.twinsoft.convertigo.beans.common.FormatedContent:
: |
page.loadGridData();
↓ButtonAddUsersToGroup [ngx.components.UIDynamicElement-1740592291305]:
beanData: |
'{
Expand Down Expand Up @@ -1998,7 +2119,7 @@ title: Title for adminDashboardUsersWithinGroups
page.performBulk("delete", "sure_delete_rows","delete_row_confirm", "delete_row_error", "cancel_pwamsg", "Supprimer");
isEnabled: false
showModalUser [ngx.components.UICustomAsyncAction-1740592291320]:
showModalAddUsersToGroup [ngx.components.UICustomAsyncAction-1740592291320]:
actionValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.FormatedContent
Expand Down Expand Up @@ -2296,6 +2417,7 @@ title: Title for adminDashboardUsersWithinGroups
console.log(page.myaggrid2?.agGrid?.api, " ",event);
page.local.selected = page.myaggrid2?.agGrid?.api?.getSelectedNodes({ startRow: 0, endRow: 1 }).length > 0;
page.global.selectedUsers = page.myaggrid2?.agGrid?.api?.getSelectedNodes();
console.log(page.global.selectedUsers);
page.ref.detectChanges();
return;
} catch (e) {
Expand Down
12 changes: 8 additions & 4 deletions _c8oProject/mobileSharedComponents/moveUserToGroupForm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ scriptContent:
- com.twinsoft.convertigo.beans.common.FormatedContent:
: |
' try {
console.log(page.myaggrid3?.agGrid?.api, " ",event);
// console.log(page.myaggrid3?.agGrid?.api, " ",event);
page.local.selected = page.myaggrid3?.agGrid?.api?.getSelectedNodes({ startRow: 0, endRow: 1 }).length > 0;
page.selectedGroups = page.myaggrid3?.agGrid?.api?.getSelectedNodes();
page.ref.detectChanges();
Expand Down Expand Up @@ -640,16 +640,20 @@ scriptContent:
let docs = page.myaggrid3?.agGrid?.api?.getSelectedNodes().map((node) => { return { "group": node.data.group} });
let docs2 = page.global.selectedUsers.map((node) => { return {"user": node.data["~c8oAcl"]}});
var deleted : any = {success: true};
var deleted2 : any = {success: true};
var deleted2 : any = {success: true};
// console.log(page.myaggrid3?.agGrid?.api?.getSelectedNodes());
// console.log(page.global.selectedUsers);
// console.log(docs, docs2)
for(let i = 0; i < docs.length;i++) {
for (let j = 0; j < docs2.length; j++) {
let args = {meta: JSON.stringify({group: docs[i].group, user: docs2[j].user})};
let args2 = {meta: JSON.stringify({group: docs[i].group, user: page.global.groupSelected})};
console.log(args);
let args2 = {meta: JSON.stringify({group: page.global.groupSelected, user: docs2[j].user})};
// console.log(args, args2);
let sequence2 = "C8Oforms.admin_user_delete_from_group";
let sequence = "C8Oforms.admin_user_add_to_group";
deleted = await page.c8o.callJsonObject(sequence, args).async();
deleted2 = await page.c8o.callJsonObject(sequence2, args2).async()
// console.log(deleted, deleted2);
}
}
Expand Down
2 changes: 1 addition & 1 deletion _c8oProject/sequences/admin_users_get_by_group_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ comment: Retrieves multiple user's information, requires admin privileges.
values: valuesRows
};
var filtered = groups;
filtered.push({group:{text:"any_group"}});
// filtered.push({group:{text:"any_group"}});
filtered.unshift({group:{text:"all_users", attr: {users: String(rows.length)}}});
var values = [];
var obj = {};
Expand Down
Loading

0 comments on commit 79ae301

Please sign in to comment.