Skip to content

Commit

Permalink
PT-14265: Provide better management and flexibility when working with…
Browse files Browse the repository at this point in the history
… metaFormsService and widgetService (#2718)

feat: Added unregisterWidget method, which allows you to remove a specific widget from a container.
feat: Added getWidgets method to retrieve the collection of widgets associated with a particular container.
feat: Added clearWidgets method to clear widgets associated with a particular container.
feat: Added unregisterMetaFields. This method allows you to remove a specific meta field from a given meta form by specifying the meta field to be unregistered.
feat: Added clearMetaFields: This method allows you to clear all registered meta fields for a specific meta form.
  • Loading branch information
OlegoO authored Nov 3, 2023
1 parent 00a1bc7 commit 70e9152
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('platformWebApp')
angular.module('platformWebApp')
.factory('platformWebApp.widgetService', function () {

var retVal = {
Expand All @@ -8,8 +8,21 @@
this.widgetsMap[containerName] = [];
}
this.widgetsMap[containerName].push(widget);
},
unregisterWidget: function (widget, containerName) {
if (this.widgetsMap[containerName]) {
var index = this. widgetsMap[containerName].indexOf(widget);
if (index !== -1) {
this.widgetsMap[containerName].splice(index, 1);
}
}
},
getWidgets: function (containerName) {
return this.widgetsMap[containerName] || [];
},
clearWidgets: function (containerName) {
this.widgetsMap[containerName] = [];
}

};
return retVal;
})
Expand Down Expand Up @@ -56,4 +69,4 @@

}
}
}]);
}]);
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ angular.module('platformWebApp')
},
getMetaFields: function (metaFormName) {
return registeredMetaFields[metaFormName];
},
unregisterMetaFields: function (metaFormName, metaField) {
if (registeredMetaFields[metaFormName]) {
var index = registeredMetaFields[metaFormName].indexOf(metaField);
if (index !== -1) {
registeredMetaFields[metaFormName].splice(index, 1);
}
}
},
clearMetaFields: function (metaFormName) {
registeredMetaFields[metaFormName] = [];
}
};
}])
Expand Down

0 comments on commit 70e9152

Please sign in to comment.