Skip to content

Commit

Permalink
feat: Allow to apply Space Template in Bulk - MEED-7768 - Meeds-io/MI…
Browse files Browse the repository at this point in the history
…Ps#160

This change will prepare the Bulk operations UX in Spaces Administration UI by adding the first bulk operation in order to apply a Space template on a set of spaces.
  • Loading branch information
boubaker committed Nov 12, 2024
1 parent 176e202 commit 17518b0
Show file tree
Hide file tree
Showing 15 changed files with 519 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,10 @@ public static ProfileEntity buildEntityProfile(Profile profile, String restPath,
} else {
userEntity.setPrimaryProperty("");
}
} else {
} else if (StringUtils.isNotBlank(userEntity.getPosition())) {
userEntity.setPrimaryProperty(userEntity.getPosition());
} else {
userEntity.setPrimaryProperty("");
}
if (userCardSecondFieldSetting != null) {
String propertyName = String.valueOf(userCardSecondFieldSetting.getValue());
Expand All @@ -504,8 +506,10 @@ public static ProfileEntity buildEntityProfile(Profile profile, String restPath,
} else {
userEntity.setSecondaryProperty("");
}
} else {
} else if (StringUtils.isNotBlank(userEntity.getTeam())) {
userEntity.setSecondaryProperty(userEntity.getTeam());
} else {
userEntity.setSecondaryProperty("");
}

if (userCardThirdFieldSetting != null) {
Expand All @@ -518,8 +522,10 @@ public static ProfileEntity buildEntityProfile(Profile profile, String restPath,
} else {
userEntity.setTertiaryProperty("");
}
} else {
} else if (StringUtils.isNotBlank(userEntity.getCity())) {
userEntity.setTertiaryProperty(userEntity.getCity());
} else {
userEntity.setTertiaryProperty("");
}

return userEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,7 @@ social.spaces.administration.manageSpaces.spaceTemplateCharacteristicsUpdateErro
social.spaces.administration.manageSpaces.allDisplayedSpacesSelected=All {0} spaces on this page are selected. {1}Select all {2} items matching the current filter{3}
social.spaces.administration.manageSpaces.selectedSpacesCount={0} Selected spaces
social.spaces.administration.manageSpaces.allSpacesSelected=All {0} spaces Selected
social.spaces.administration.manageSpaces.applyOnlyOnEmptyTemplate=Apply only on spaces not using a template
social.spaces.administration.manageSpaces.processingSpacesBulkOperation=Applying changes on spaces...
social.spaces.administration.manageSpaces.spaceTemplateAppliedOnSpaces=Spaces updated with selected template
social.spaces.administration.manageSpaces.processingSpacesBulkOperationCancelConfirm=Reloading the page will cancel non-processed spaces. Do you confirm cancellation?
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
:max-width="maxWidth"
:min-height="minHeight"
:dense="isMobile"
:dismissible="!isMobile"
:dismissible="!isMobile && alertDismissible"
:icon="false"
:border="!isMobile && 'left' || false"
:class="isMobile && 'no-border-radius b-0 mb-0' || 'mb-5'"
Expand Down Expand Up @@ -72,6 +72,11 @@
v-sanitized-html="alertMessage"
@click="handleAlertClicked">
</span>
<component
v-if="alertComponent"
:is="alertComponent"
v-bind="alertComponentParams"
class="text-body flex-grow-1 mx-4" />
<span v-else class="text-body flex-grow-1 me-4">
{{ alertMessage }}
</span>
Expand All @@ -90,7 +95,7 @@
<v-icon v-else-if="alertLinkIcon">{{ alertLinkIcon }}</v-icon>
</v-btn>
</div>
<template v-if="!isMobile" #close="{toggle}">
<template v-if="!isMobile && alertDismissible" #close="{toggle}">
<v-btn
icon
@click="dismiss(toggle)">
Expand All @@ -112,6 +117,9 @@ export default {
alertLink: null,
alertLinkCallback: null,
alertDismissCallback: null,
alertComponent: null,
alertComponentParams: null,
alertDismissible: true,
alertLinkIcon: null,
alertLinkText: null,
alertLinkTarget: null,
Expand Down Expand Up @@ -254,6 +262,10 @@ export default {
this.alertLinkTooltip = params.alertLinkTooltip || null;
this.alertLinkCallback = params.alertLinkCallback || null;
this.alertDismissCallback = params.alertDismissCallback || null;
this.alertComponent = params.alertComponent || null;
this.alertComponentParams = params.alertComponentParams || null;
this.alertDismissible = Object.hasOwn(params, 'alertDismissible') ? params.alertDismissible : true;
this.timeout = params.alertTimeout || 10000;
this.timeoutInstance = window.setTimeout(() => this.snackbar = true, 500);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,13 @@
<v-app>
<v-main class="application-body">
<spaces-administration-toolbar
:selected-template-id="selectedTemplateId"
@keyword-changed="keyword = $event"
@template-changed="selectedTemplateId = $event"
@loading="loadingSpaces = loadingSpaces || $event" />
:selected-template-id="$root.selectedTemplateId"
@keyword-changed="$root.keyword = $event"
@template-changed="$root.selectedTemplateId = $event"
@loading="$root.loadingSpaces = $root.loadingSpaces || $event" />
<spaces-administration-list
ref="spacesList"
:keyword="keyword"
:loading-spaces="loadingSpaces"
:selected-template-id="selectedTemplateId"
class="px-5"
@loading-spaces="loadingSpaces = $event"
@loaded="spacesLoaded" />
class="px-5" />
</v-main>
<div>
<component
Expand All @@ -58,13 +53,5 @@ export default {
initialized: false,
selectedTemplateId: '0',
}),
methods: {
spacesLoaded() {
if (!this.initialized) {
this.$root.$applicationLoaded();
this.initialized = true;
}
}
},
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--

This file is part of the Meeds project (https://meeds.io/).

Copyright (C) 2020 - 2024 Meeds Association contact@meeds.io

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

-->
<template>
<v-btn
:disabled="$root.isBulkProcessing"
color="primary"
elevation="0"
outlined
@click="$root.$emit('space-administration-apply-template-drawer-open', $root.selectedSpaces, $root.allSpacesSelected ? $root.spacesSize : $root.selectedSpaces.length, applyTemplate)">
<v-icon size="16" class="me-2">fa-sitemap</v-icon>
{{ $t('social.spaces.administration.manageSpaces.applyTemplate') }}
</v-btn>
</template>
<script>
export default {
data: () => ({
successMessage: null,
}),
methods: {
applyTemplate(params) {
// Workaround for context change, compute success message on processing start
this.successMessage = this.$t('social.spaces.administration.manageSpaces.spaceTemplateAppliedOnSpaces');
this.$root.applyOperationInBulk(
(space, options) => this.$spaceAdministrationService.applySpaceTemplate(space.id, options),
params,
() => {
this.$root.$emit('alert-message', this.successMessage, 'success');
this.$root.$emit('spaces-administration-list-refresh');
});
},
},
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!--

This file is part of the Meeds project (https://meeds.io/).

Copyright (C) 2020 - 2024 Meeds Association contact@meeds.io

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

-->
<template>
<div class="d-flex">
<div class="me-2">{{ $t('social.spaces.administration.manageSpaces.processingSpacesBulkOperation') }}</div>
<strong>{{ processedSpaces }} / {{ selectedSpacesCount }}</strong>
</div>
</template>
<script>
export default {
props: {
options: {
type: Object,
default: null,
},
},
computed: {
processedSpaces() {
return this.options.processedSpaces;
},
selectedSpacesCount() {
return this.options.allSpacesSelected ? this.options.spacesSize : this.options.selectedSpaces.length;
},
},
};
</script>
Loading

0 comments on commit 17518b0

Please sign in to comment.