Skip to content

Commit

Permalink
feat: Remove Mandatory Flag in Space Form inputs - MEED-7750 - Meeds-…
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker committed Nov 11, 2024
1 parent 096aded commit a31c7af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ private void copySpaceTemplateProperties(Space space,
String username,
List<String> invitees) throws SpaceException {
setSpaceAccess(space, spaceTemplate);
setSpaceDisplayName(space, spaceTemplate, invitees);
setSpaceDisplayName(space, invitees);
// Creates the associated group to the space
String groupId = createSpaceGroup(space, username);
setDeletePermissions(space, spaceTemplate, groupId);
Expand Down Expand Up @@ -1009,9 +1009,8 @@ private void setSpaceAccess(Space space, SpaceTemplate spaceTemplate) {
}
}

private void setSpaceDisplayName(Space space, SpaceTemplate spaceTemplate, List<String> invitees) throws SpaceException {
if (!spaceTemplate.getSpaceFields().contains("name")
&& StringUtils.isBlank(space.getDisplayName())) {
private void setSpaceDisplayName(Space space, List<String> invitees) throws SpaceException {
if (StringUtils.isBlank(space.getDisplayName())) {
if (CollectionUtils.isNotEmpty(invitees)) {
invitees = new ArrayList<>(invitees);
invitees.removeAll(Arrays.asList(space.getMembers()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,29 +870,15 @@ public void testCreateSpaceNameTooShort() {
assertThrows(SpaceException.class, () -> spaceService.createSpace(space, ROOT_NAME));
}

public void testCreateSpaceWithNoNameWhenSpaceTemplateAllowsIt() throws ObjectNotFoundException {
SpaceTemplateService spaceTemplateService = getService(SpaceTemplateService.class);
SpaceTemplate spaceTemplate = spaceTemplateService.getSpaceTemplates().getFirst();
List<String> originalSpaceFields = spaceTemplate.getSpaceFields();

try {
Space space = new Space();
space.setRegistration(Space.OPEN);
space.setDescription(SPACE_DESCRIPTION);
space.setVisibility(Space.PUBLIC);
space.setRegistration(Space.VALIDATION);
assertThrows(SpaceException.class, () -> spaceService.createSpace(space, ROOT_NAME));

spaceTemplate.setSpaceFields(Collections.singletonList("invitation"));
spaceTemplateService.updateSpaceTemplate(spaceTemplate);

Space createdSpace = spaceService.createSpace(space, DRAGON_NAME);
assertNotNull(createdSpace);
assertEquals("Dragon Ball", createdSpace.getDisplayName());
} finally {
spaceTemplate.setSpaceFields(originalSpaceFields);
spaceTemplateService.updateSpaceTemplate(spaceTemplate);
}
public void testCreateSpaceWithNoName() {
Space space = new Space();
space.setRegistration(Space.OPEN);
space.setDescription(SPACE_DESCRIPTION);
space.setVisibility(Space.PUBLIC);
space.setRegistration(Space.VALIDATION);
Space createdSpace = spaceService.createSpace(space, DRAGON_NAME);
assertNotNull(createdSpace);
assertEquals("Dragon Ball", createdSpace.getDisplayName());
}

public void testCreateSpaceWithTemplateCharacteristics() throws ObjectNotFoundException, SpaceException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
<input
ref="autoFocusInput1"
v-model="space.displayName"
v-bind="nameIsRequired && {
required: 'required',
}"
:aria-label="$t('spacesList.label.displayName')"
:placeholder="$t('spacesList.label.displayName')"
type="text"
Expand Down Expand Up @@ -194,7 +191,6 @@
v-model="space.invitedMembers"
:labels="suggesterLabels"
:disabled="savingSpace || spaceSaved"
:required="invitationIsRequired"
:search-options="{
spaceURL: space.prettyName,
}"
Expand Down Expand Up @@ -269,8 +265,7 @@ export default {
return this.savingSpace
|| this.spaceSaved
|| this.stepper < 3 && !this.space.id
|| (this.space.description?.length || 0) > this.maxDescriptionLength
|| (this.invitationIsRequired && !this.space.invitedMembers?.length);
|| (this.space.description?.length || 0) > this.maxDescriptionLength;
},
sortedTemplates() {
const spaceTemplates = this.templates?.filter?.(t => t.name) || [];
Expand All @@ -285,12 +280,6 @@ export default {
spaceTemplate() {
return this.templates?.find?.(temp => temp.id === this.templateId);
},
nameIsRequired() {
return this.spaceTemplate?.spaceFields?.includes?.('name');
},
invitationIsRequired() {
return this.spaceTemplate?.spaceFields?.includes?.('invitation');
},
displayedForm() {
return this.$refs && this.$refs[`form${this.stepper}`];
},
Expand Down Expand Up @@ -411,7 +400,7 @@ export default {
return;
}
this.spaceToUpdate = space;
this.space = Object.assign({}, space);
this.space = {...space};
this.templateId = this.space.templateId;
this.title = this.$t('spacesList.label.editSpace', { 0: this.space.displayName });
this.$spaceTemplateService.getSpaceTemplates()
Expand Down

0 comments on commit a31c7af

Please sign in to comment.