Skip to content

Commit

Permalink
feat: Allow to add, edit and delete a category - MEED-6912 - Meeds-io…
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker committed May 29, 2024
1 parent b46a097 commit 9b6140b
Show file tree
Hide file tree
Showing 29 changed files with 565 additions and 1,744 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public class PortletInstanceCategory {

private String name;

private String description;

private String icon;

private boolean system;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@
@Order(Ordered.HIGHEST_PRECEDENCE)
public class PortletInstanceCategoryTranslationPlugin extends TranslationPlugin {

public static final String OBJECT_TYPE = "portletInstanceCategory";
public static final String OBJECT_TYPE = "portletInstanceCategory";

public static final String DESCRIPTION_FIELD_NAME = "description";

public static final String TITLE_FIELD_NAME = "title";
public static final String TITLE_FIELD_NAME = "title";

@Autowired
private LayoutAclService layoutAclService;
Expand All @@ -53,7 +51,7 @@ public class PortletInstanceCategoryTranslationPlugin extends TranslationPlugin
private PortletInstanceService portletInstanceService;

@Autowired
private TranslationService translationService;
private TranslationService translationService;

@PostConstruct
public void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ private void computePortletInstanceCategoryAttributes(Locale locale, PortletInst
portletInstanceCategory.getId(),
PortletInstanceCategoryTranslationPlugin.TITLE_FIELD_NAME,
locale));
portletInstanceCategory.setDescription(getLabel(PortletInstanceCategoryTranslationPlugin.OBJECT_TYPE,
portletInstanceCategory.getId(),
PortletInstanceCategoryTranslationPlugin.DESCRIPTION_FIELD_NAME,
locale));
}

private String getLabel(String objectType, long objectId, String fieldName, Locale locale) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ protected void importPortletInstanceCategory(PortletInstanceCategoryDescriptor d
if (forceReimport || oldId == 0 || category.getId() != oldId) {
LOG.info("Importing Portlet instance category {} title translations", descriptorId);
saveCategoryNames(d, category);
LOG.info("Importing Portlet instance category {} description translations", descriptorId);
saveCategoryDescriptions(d, category);
// Mark as imported
setCategorySettingValue(descriptorId, category.getId());
}
Expand Down Expand Up @@ -259,13 +257,6 @@ protected void saveCategoryNames(PortletInstanceCategoryDescriptor d, PortletIns
d.getNames());
}

protected void saveCategoryDescriptions(PortletInstanceCategoryDescriptor d, PortletInstanceCategory category) {
layoutTranslationService.saveTranslationLabels(PortletInstanceCategoryTranslationPlugin.OBJECT_TYPE,
category.getId(),
PortletInstanceCategoryTranslationPlugin.DESCRIPTION_FIELD_NAME,
d.getDescriptions());
}

@SneakyThrows
protected PortletInstanceCategory savePortletInstanceCategory(PortletInstanceCategoryDescriptor d, long oldId) {
PortletInstanceCategory category = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ private EntityMapper() {

public static PortletInstanceCategory fromEntity(PortletInstanceCategoryEntity entity) {
return new PortletInstanceCategory(entity.getId(),
null,
null,
entity.getIcon(),
entity.isSystem(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"names":{
"en":"layout.portletInstance.category.content.name"
},
"descriptions":{
"en":"layout.portletInstance.category.content.description"
},
"icon":"fa-newspaper",
"permissions":[
"*:/platform/users"
Expand All @@ -19,9 +16,6 @@
"names":{
"en":"layout.portletInstance.category.tools.name"
},
"descriptions":{
"en":"layout.portletInstance.category.tools.description"
},
"icon":"fa-tools",
"permissions":[
"*:/platform/users"
Expand All @@ -33,9 +27,6 @@
"names":{
"en":"layout.portletInstance.category.spaceTools.name"
},
"descriptions":{
"en":"layout.portletInstance.category.spaceTools.description"
},
"icon":"fa-users-cog",
"permissions":[
"*:/platform/users"
Expand All @@ -47,9 +38,6 @@
"names":{
"en":"layout.portletInstance.category.profile.name"
},
"descriptions":{
"en":"layout.portletInstance.category.profile.description"
},
"icon":"fa-user",
"permissions":[
"*:/platform/users"
Expand All @@ -61,10 +49,7 @@
"names":{
"en":"layout.portletInstance.category.spaces.name"
},
"descriptions":{
"en":"layout.portletInstance.category.spaces.description"
},
"icon":"fa-tools",
"icon":"fa-people-arrows",
"permissions":[
"*:/platform/users"
],
Expand All @@ -75,9 +60,6 @@
"names":{
"en":"layout.portletInstance.category.userSettings.name"
},
"descriptions":{
"en":"layout.portletInstance.category.userSettings.description"
},
"icon":"fa-user-cog",
"permissions":[
"*:/platform/users"
Expand All @@ -89,9 +71,6 @@
"names":{
"en":"layout.portletInstance.category.navigation.name"
},
"descriptions":{
"en":"layout.portletInstance.category.navigation.description"
},
"icon":"fa-project-diagram",
"permissions":[
"*:/platform/users"
Expand All @@ -103,9 +82,6 @@
"names":{
"en":"layout.portletInstance.category.others.name"
},
"descriptions":{
"en":"layout.portletInstance.category.others.description"
},
"icon":"fa-ellipsis-h",
"permissions":[
"*:/platform/users"
Expand Down
45 changes: 45 additions & 0 deletions layout-service/src/main/resources/portlet-instances.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,51 @@
],
"system":true
},
{
"nameId":"UserSettingLanguage",
"categoryNameId":"userSettings",
"portletName":"UserSettingLanguage",
"names":{
"en":"layout.portletInstance.UserSettingLanguage.name"
},
"descriptions":{
"en":"layout.portletInstance.UserSettingLanguage.description"
},
"permissions":[
"*:/platform/users"
],
"system":true
},
{
"nameId":"UserSettingNotifications",
"categoryNameId":"userSettings",
"portletName":"UserSettingNotifications",
"names":{
"en":"layout.portletInstance.UserSettingNotifications.name"
},
"descriptions":{
"en":"layout.portletInstance.UserSettingNotifications.description"
},
"permissions":[
"*:/platform/users"
],
"system":true
},
{
"nameId":"UserSettingSecurity",
"categoryNameId":"userSettings",
"portletName":"UserSettingSecurity",
"names":{
"en":"layout.portletInstance.UserSettingSecurity.name"
},
"descriptions":{
"en":"layout.portletInstance.UserSettingSecurity.description"
},
"permissions":[
"*:/platform/users"
],
"system":true
},
{
"nameId":"ProfileAboutMe",
"categoryNameId":"profile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ public void getPortletInstanceCategories() {
assertEquals(portletInstanceCategory.getId(), portletInstanceCategories.get(0).getId());
assertEquals(portletInstanceCategory.getIcon(), portletInstanceCategories.get(0).getIcon());
assertNull(portletInstanceCategories.get(0).getName());
assertNull(portletInstanceCategories.get(0).getDescription());
}

@Test
Expand All @@ -351,7 +350,6 @@ public void getPortletInstanceCategoriesWithExpand() throws ObjectNotFoundExcept
assertEquals(category.getId(), portletInstanceCategorys.get(0).getId());
assertEquals(category.getIcon(), portletInstanceCategorys.get(0).getIcon());
assertNull(portletInstanceCategorys.get(0).getName());
assertNull(portletInstanceCategorys.get(0).getDescription());

when(translationService.getTranslationField(PortletInstanceCategoryTranslationPlugin.OBJECT_TYPE,
category.getId(),
Expand All @@ -372,7 +370,6 @@ public void getPortletInstanceCategoriesWithExpand() throws ObjectNotFoundExcept
assertEquals(category.getId(), portletInstanceCategorys.get(0).getId());
assertEquals(category.getIcon(), portletInstanceCategorys.get(0).getIcon());
assertNull(portletInstanceCategorys.get(0).getName());
assertNull(portletInstanceCategorys.get(0).getDescription());

String frTitle = TITLE;
when(titleTranslationField.getLabels()).thenReturn(Collections.singletonMap(Locale.FRENCH, frTitle));
Expand All @@ -382,17 +379,9 @@ public void getPortletInstanceCategoriesWithExpand() throws ObjectNotFoundExcept
assertEquals(1, portletInstanceCategorys.size());
assertEquals(frTitle, portletInstanceCategorys.get(0).getName());

TranslationField descriptionTranslationField = mock(TranslationField.class);
when(translationService.getTranslationField(PortletInstanceCategoryTranslationPlugin.OBJECT_TYPE,
category.getId(),
PortletInstanceCategoryTranslationPlugin.DESCRIPTION_FIELD_NAME)).thenReturn(descriptionTranslationField);
String enDesc = DESCRIPTION;
when(descriptionTranslationField.getLabels()).thenReturn(Collections.singletonMap(Locale.ENGLISH, enDesc));

portletInstanceCategorys = portletInstanceService.getPortletInstanceCategories(Locale.ENGLISH, true);
assertNotNull(portletInstanceCategorys);
assertEquals(1, portletInstanceCategorys.size());
assertEquals(enDesc, portletInstanceCategorys.get(0).getDescription());
}

@Test
Expand Down Expand Up @@ -426,24 +415,15 @@ public void getPortletInstanceCategoryWithExpand() throws ObjectNotFoundExceptio
assertEquals(category.getId(), retrievedPortletInstanceCategory.getId());
assertEquals(category.getIcon(), retrievedPortletInstanceCategory.getIcon());
assertNull(retrievedPortletInstanceCategory.getName());
assertNull(retrievedPortletInstanceCategory.getDescription());

String frTitle = TITLE;
when(titleTranslationField.getLabels()).thenReturn(Collections.singletonMap(Locale.FRENCH, frTitle));

retrievedPortletInstanceCategory = portletInstanceService.getPortletInstanceCategory(category.getId(), Locale.FRENCH, true);
assertEquals(frTitle, retrievedPortletInstanceCategory.getName());

TranslationField descriptionTranslationField = mock(TranslationField.class);
when(translationService.getTranslationField(PortletInstanceCategoryTranslationPlugin.OBJECT_TYPE,
category.getId(),
PortletInstanceCategoryTranslationPlugin.DESCRIPTION_FIELD_NAME)).thenReturn(descriptionTranslationField);
String enDesc = DESCRIPTION;
when(descriptionTranslationField.getLabels()).thenReturn(Collections.singletonMap(Locale.ENGLISH, enDesc));

retrievedPortletInstanceCategory = portletInstanceService.getPortletInstanceCategory(category.getId(), Locale.ENGLISH, true);
assertNotNull(retrievedPortletInstanceCategory);
assertEquals(enDesc, retrievedPortletInstanceCategory.getDescription());
}

@Test
Expand Down Expand Up @@ -508,7 +488,6 @@ public void updatePortletInstanceCategory() throws ObjectNotFoundException, Ille

private PortletInstanceCategory newPortletInstanceCategory() {
return new PortletInstanceCategory(3l,
null,
null,
"icon",
true,
Expand Down
3 changes: 2 additions & 1 deletion layout-webapp/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
],
"globals": {
"jQuery": true,
"echarts": true
"echarts": true,
"fontLibrary": true
},
"rules": {
"vue/multi-word-component-names": "off",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pageTemplate.label.confirm=Confirm
pageTemplate.label.cancel=Cancel
portlets=Portlets
portlets.instances=instances
portlets.instances=Instances
portlets.filter.placeholder=Filter by name, description
portlets.label.disableInstance=Disable instance
portlets.label.enableInstance=Enable instance
Expand All @@ -158,9 +158,13 @@ portlets.status.update.error=An unknown error occurred while updating instance.
portlets.layout.update.success=Portlet instance successfully updated
portlets.layout.update.error=An unknown error occurred while updating instance. Please contact the administrator or try agan later.
portlets.delete.success=Portlet instance successfully deleted
portlets.category.delete.success=Portlet instance category successfully deleted
portlets.delete.error=An unknown error occurred while deleting instance. Please contact the administrator or try agan later.
portlets.label.confirmDeleteTitle=Delete page template?
portlets.label.confirmDeleteMessage=Would you like to delete page template: {0}
portlets.category.delete.error=An unknown error occurred while deleting category. Please contact the administrator or try agan later.
portlets.label.confirmDeleteTitle=Delete portlet instance?
portlets.label.confirmDeleteCategoryTitle=Delete category?
portlets.label.confirmDeleteMessage=Would you like to delete portlet instance : {0}
portlets.label.confirmDeleteCategoryMessage=Would you like to delete portlet instance category : {0}
portlets.label.confirm=Confirm
portlets.label.cancel=Cancel
portlets.label.name=Name
Expand All @@ -179,6 +183,7 @@ portlets.label.system.noEditLayout=This portlet instance's layout cannot be upda
portlets.label.editProperties=Edit Properties
portlets.label.duplicate=Duplicate
portlets.label.delete=Delete
portlets.label.edit=Edit
portlets.label.system.noDelete=This portlet instance cannot be deleted
portlets.label.category.system.noDelete=This category cannot be deleted
portlets.label.preview=Preview of {0}
Expand Down Expand Up @@ -235,22 +240,26 @@ layout.portletInstance.ProfileWorkExperience.description=List of experiences of

layout.portletInstance.category.all.name=All
layout.portletInstance.category.others.name=Others
layout.portletInstance.category.others.description=Other applications
layout.portletInstance.category.spaces.name=Space
layout.portletInstance.category.spaces.description=Spaces applications
layout.portletInstance.category.spaces.name=Space Applications
layout.portletInstance.category.spaceTools.name=Space Tools
layout.portletInstance.category.spaceTools.description=Spaces Tools applications
layout.portletInstance.category.content.name=Content
layout.portletInstance.category.content.description=Content Applications
layout.portletInstance.category.tools.name=General Tools
layout.portletInstance.category.tools.description=General Tools
layout.portletInstance.category.spaceTools.name=Space Tools
layout.portletInstance.category.spaceTools.description=Space Tools
layout.portletInstance.category.navigation.name=Navigation
layout.portletInstance.category.navigation.description=Applications for Navigation
layout.portletInstance.category.userSettings.name=User Settings
layout.portletInstance.category.userSettings.description=Applications for User Settings
layout.portletInstance.category.profile.name=Profile
layout.portletInstance.category.profile.description=Applications for Profile
portlets.portletInstancesList=Instances using Links
portlets.noPortletInstancesYet=No instance is using this portlet for now

layout.portletInstance.category.drawerTitie.add=Add a category
layout.portletInstance.category.drawerTitie.edit=Edit a category
layout.portletInstance.category=Category
layout.portletInstance.category.name=Name
layout.portletInstance.category.namePlaceholder=Name
layout.portletInstance.category.nameTranslationDrawerTitle=Category name translations
layout.portletInstance.category.icon=Icon

layout.portletInstanceCategoryCreatedSuccessfully=Portlet Instance Category created successfully
layout.portletInstanceCategoryUpdatedSuccessfully=Portlet Instance Category updated successfully

portlets.portletInstancesList=Instances using {0}
portlets.previewInstance=Preview the instance
portlets.noPortletInstancesYet=No instance is using this portlet for now
Loading

0 comments on commit 9b6140b

Please sign in to comment.