Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team verwalten: Rollen #1416

Merged
merged 10 commits into from
Jul 14, 2021
9 changes: 8 additions & 1 deletion backend/content-type/eCampMultiSelect/src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@ public function onBootstrap(MvcEvent $e): void {
Option::class,
[Acl::REST_PRIVILEGE_FETCH_ALL]
);

$acl->allow(
User::ROLE_USER,
Option::class,
[Acl::REST_PRIVILEGE_FETCH],
new UserIsCollaborator([CampCollaboration::ROLE_MEMBER, CampCollaboration::ROLE_MANAGER, CampCollaboration::ROLE_GUEST])
);

$acl->allow(
User::ROLE_USER,
Option::class,
[
Acl::REST_PRIVILEGE_CREATE,
Acl::REST_PRIVILEGE_FETCH,
Acl::REST_PRIVILEGE_PATCH,
Acl::REST_PRIVILEGE_UPDATE,
Acl::REST_PRIVILEGE_DELETE,
Expand Down
9 changes: 8 additions & 1 deletion backend/content-type/eCampSingleText/src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@ public function onBootstrap(MvcEvent $e): void {
SingleText::class,
[Acl::REST_PRIVILEGE_FETCH_ALL]
);

$acl->allow(
User::ROLE_USER,
SingleText::class,
[Acl::REST_PRIVILEGE_FETCH],
new UserIsCollaborator([CampCollaboration::ROLE_MEMBER, CampCollaboration::ROLE_MANAGER, CampCollaboration::ROLE_GUEST])
);

$acl->allow(
User::ROLE_USER,
SingleText::class,
[
Acl::REST_PRIVILEGE_CREATE,
Acl::REST_PRIVILEGE_FETCH,
Acl::REST_PRIVILEGE_PATCH,
Acl::REST_PRIVILEGE_UPDATE,
Acl::REST_PRIVILEGE_DELETE,
Expand Down
9 changes: 8 additions & 1 deletion backend/content-type/eCampStoryboard/src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@ public function onBootstrap(MvcEvent $e): void {
Section::class,
[Acl::REST_PRIVILEGE_FETCH_ALL]
);

$acl->allow(
User::ROLE_USER,
Section::class,
[Acl::REST_PRIVILEGE_FETCH],
new UserIsCollaborator([CampCollaboration::ROLE_MEMBER, CampCollaboration::ROLE_MANAGER, CampCollaboration::ROLE_GUEST])
);

$acl->allow(
User::ROLE_USER,
Section::class,
[
Acl::REST_PRIVILEGE_CREATE,
Acl::REST_PRIVILEGE_FETCH,
Acl::REST_PRIVILEGE_PATCH,
Acl::REST_PRIVILEGE_UPDATE,
Acl::REST_PRIVILEGE_DELETE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
->addValidatorInArray([
CampCollaboration::ROLE_MEMBER,
CampCollaboration::ROLE_MANAGER,
CampCollaboration::ROLE_GUEST,
])
)
->buildConfig()
Expand Down
11 changes: 9 additions & 2 deletions backend/module/eCampApi/test/Rest/CampCollaborationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,13 @@ public function testCreateSuccess(): void {
$this->assertEquals(CampCollaboration::STATUS_INVITED, $this->getResponseContent()->status);
}

public function testCreateOnlyWithEmail(): void {
/**
* @dataProvider getRoles
*/
public function testCreateOnlyWithEmail(string $role): void {
$inviteEmail = 'my.mail@fantasy.com';
$this->setRequestContent([
'role' => CampCollaboration::ROLE_MEMBER,
'role' => $role,
'campId' => $this->campCollaboration1->getCamp()->getId(),
'inviteEmail' => $inviteEmail,
'userId' => null,
Expand All @@ -244,6 +247,10 @@ public function testCreateOnlyWithEmail(): void {
$this->assertThat($this->getResponseContent()->_embedded, self::logicalNot(self::classHasAttribute('user')));
}

public static function getRoles(): array {
return [[CampCollaboration::ROLE_GUEST], [CampCollaboration::ROLE_MANAGER], [CampCollaboration::ROLE_MEMBER]];
}

public function testCreateWithEmailOfExistingUser() {
$inviteEmail = 'my.mail@fantasy.com';
$user2 = new User();
Expand Down
2 changes: 1 addition & 1 deletion backend/module/eCampCore/src/Acl/AclFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
Acl::REST_PRIVILEGE_FETCH,
AclAssertion::or(
new CampIsPrototype(),
new UserIsCollaborator([CampCollaboration::ROLE_MEMBER, CampCollaboration::ROLE_MANAGER])
new UserIsCollaborator([CampCollaboration::ROLE_MEMBER, CampCollaboration::ROLE_MANAGER, CampCollaboration::ROLE_GUEST])
)
);
$acl->allow(
Expand Down
3 changes: 2 additions & 1 deletion common/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"collaborators": {
"invite": "Invite",
"manager": "Manager",
"member": "Member"
"member": "Member",
"guest": "Guest"
},
"fields": {
"addressCity": "City",
Expand Down
16 changes: 12 additions & 4 deletions frontend/src/components/activity/CardContentNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<v-card :elevation="draggable ? 4 : 0" :class="{ 'mx-2 my-2': draggable }">
<v-card-title hide-actions class="pa-0 pr-sm-2">
<v-toolbar dense flat>
<v-menu bottom
<v-menu v-if="!disabled"
bottom
right
offset-y>
<template #activator="{ on, attrs }">
Expand All @@ -26,6 +27,9 @@
</v-row>
</v-container>
</v-menu>
<v-icon v-else>
{{ currentIcon }}
</v-icon>

<div
v-if="editInstanceName"
Expand All @@ -46,7 +50,7 @@
</v-toolbar-title>
</div>

<v-menu v-if="!layoutMode"
<v-menu v-if="!layoutMode && !disabled"
bottom
left
offset-y>
Expand All @@ -67,7 +71,7 @@
</v-list>
</v-menu>
<dialog-entity-delete
v-else
v-else-if="!disabled"
:entity="contentNode">
<template #activator="{ on }">
<v-btn icon
Expand Down Expand Up @@ -101,7 +105,8 @@ export default {
props: {
contentNode: { type: Object, required: true },
layoutMode: { type: Boolean, required: true },
draggable: { type: Boolean, default: false }
draggable: { type: Boolean, default: false },
disabled: { type: Boolean, default: false }
},
data () {
return {
Expand Down Expand Up @@ -139,6 +144,9 @@ export default {
},
methods: {
toggleEditInstanceName (e) {
if (this.disabled) {
return
}
this.editInstanceName = !this.editInstanceName
}
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/activity/ContentNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:content-node="contentNode"
:layout-mode="layoutMode"
:draggable="draggable"
:disabled="disabled"
v-bind="$attrs" />
</template>

Expand Down Expand Up @@ -35,7 +36,8 @@ export default {
props: {
contentNode: { type: Object, required: true },
layoutMode: { type: Boolean, required: true },
draggable: { type: Boolean, default: false }
draggable: { type: Boolean, default: false },
disabled: { type: Boolean, default: false }
}
}
</script>
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/activity/DraggableContentNodes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
class="content-node"
:content-node="allContentNodesById[id]"
:layout-mode="layoutMode"
:draggable="draggingEnabled" />
:draggable="draggingEnabled"
:disabled="disabled" />
</draggable>

<button-nested-content-node-add v-if="layoutMode"
Expand All @@ -40,7 +41,8 @@ export default {
props: {
layoutMode: { type: Boolean, default: false },
slotName: { type: String, required: true },
parentContentNode: { type: Object, required: true }
parentContentNode: { type: Object, required: true },
disabled: { type: Boolean, default: false }
},
data () {
return {
Expand All @@ -52,7 +54,7 @@ export default {
return keyBy(this.parentContentNode.owner().contentNodes().items, 'id')
},
draggingEnabled () {
return this.layoutMode && this.$vuetify.breakpoint.mdAndUp
return this.layoutMode && this.$vuetify.breakpoint.mdAndUp && !this.disabled
},
contentNodeIds () {
return sortBy(
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/activity/content/ColumnLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
@resize-stop="saveColumnWidths">
<draggable-content-nodes :slot-name="slot"
:layout-mode="layoutMode"
:parent-content-node="contentNode" />
:parent-content-node="contentNode"
:disabled="disabled" />

<template #menu>
<column-operations :content-node="contentNode" :min-column-width="minWidth(slot)" :total-width="12" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<v-list-item v-for="option in contentNode.options().items"
:key="option.id"
tag="label"
:disabled="layoutMode">
:disabled="layoutMode || disabled">
<v-list-item-action>
<api-checkbox fieldname="checked" :uri="option._meta.self" />
</v-list-item-action>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/activity/content/Material.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
:content-node="contentNode"
:layout-mode="layoutMode"
:material-item-collection="contentNode.materialItems()"
:group-by-list="$vuetify.breakpoint.xs" />
:group-by-list="$vuetify.breakpoint.xs"
:disabled="disabled" />
</div>
</card-content-node>
</template>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/activity/content/Notes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:label="$tc('contentNode.notes.name')"
rows="4"
auto-grow
:disabled="layoutMode"
:disabled="layoutMode || disabled"
:filled="layoutMode" />
</api-form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/activity/content/SafetyConcept.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
fieldname="text"
:placeholder="$tc('contentNode.safetyConcept.name')"
rows="2"
:disabled="layoutMode"
:disabled="layoutMode || disabled"
:filled="layoutMode" />
</api-form>
</div>
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/activity/content/Storyboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,35 @@
<v-col cols="1" />
</v-row>

<api-sortable v-slot="sortable" :collection="sections">
<api-sortable v-slot="sortable" :disabled="layoutMode || disabled" :collection="sections">
<api-form :entity="sortable.entity">
<v-row dense>
<v-col cols="2">
<api-textarea
fieldname="column1"
auto-grow
rows="2"
:disabled="layoutMode"
:disabled="layoutMode || disabled"
:filled="layoutMode" />
</v-col>
<v-col cols="7">
<api-textarea
fieldname="column2"
auto-grow
rows="4"
:disabled="layoutMode"
:disabled="layoutMode || disabled"
:filled="layoutMode" />
</v-col>
<v-col cols="2">
<api-textarea
fieldname="column3"
auto-grow
rows="2"
:disabled="layoutMode"
:disabled="layoutMode || disabled"
:filled="layoutMode" />
</v-col>
<v-col cols="1">
<v-container v-if="!layoutMode" class="ma-0 pa-0">
<v-container v-if="!layoutMode && !disabled" class="ma-0 pa-0">
<v-row no-gutters>
<v-col cols="6">
<div class="section-buttons">
Expand Down Expand Up @@ -85,7 +85,7 @@
<!-- add at end position -->
<v-row no-gutters justify="center">
<v-col cols="1">
<v-btn v-if="!layoutMode"
<v-btn v-if="!layoutMode && !disabled"
icon
small
class="button-add"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/activity/content/Storycontext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:placeholder="$tc('contentNode.storycontext.name')"
rows="2"
auto-grow
:disabled="layoutMode"
:disabled="layoutMode || disabled"
:filled="layoutMode" />
</api-form>
</div>
Expand Down
16 changes: 12 additions & 4 deletions frontend/src/components/camp/CampAddress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ Displays address and allows to edit
<api-form :entity="camp()">
<api-text-field
fieldname="addressName"
:name="$tc('entity.camp.fields.addressName')" />
:name="$tc('entity.camp.fields.addressName')"
:disabled="disabled" />
<api-text-field
fieldname="addressStreet"
:name="$tc('entity.camp.fields.addressStreet')" />
:name="$tc('entity.camp.fields.addressStreet')"
:disabled="disabled" />
<api-text-field
fieldname="addressZipcode"
:name="$tc('entity.camp.fields.addressZipcode')" />
:name="$tc('entity.camp.fields.addressZipcode')"
:disabled="disabled" />
<api-text-field
fieldname="addressCity"
:name="$tc('entity.camp.fields.addressCity')" />
:name="$tc('entity.camp.fields.addressCity')"
:disabled="disabled" />
</api-form>
</div>
</content-group>
Expand All @@ -36,6 +40,10 @@ export default {
camp: {
type: Function,
required: true
},
disabled: {
type: Boolean,
default: false
}
}
}
Expand Down
Loading