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

Feature: Create checklist can select prototype-checklist #6014

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/src/Entity/Checklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
normalizationContext: ['groups' => ['read']],
order: ['camp.id', 'name'],
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['camp'])]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['camp', 'isPrototype'])]
#[ORM\Entity(repositoryClass: ChecklistRepository::class)]
class Checklist extends BaseEntity implements BelongsToCampInterface, CopyFromPrototypeInterface {
public const CAMP_SUBRESOURCE_URI_TEMPLATE = '/camps/{campId}/checklists{._format}';
Expand Down Expand Up @@ -166,7 +166,7 @@ public function copyFromPrototype($prototype, $entityMap): void {
$entityMap->add($prototype, $this);

// copy Checklist base properties
$this->name = $prototype->name;
$this->name ??= $prototype->name;

// deep copy ChecklistItems
foreach ($prototype->getChecklistItems() as $checklistItemPrototype) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24354,6 +24354,18 @@ paths:
schema:
type: string
style: form
-
allowEmptyValue: true
allowReserved: false
deprecated: false
description: ''
explode: false
in: query
name: isPrototype
required: false
schema:
type: boolean
style: form
-
allowEmptyValue: true
allowReserved: false
Expand All @@ -24368,6 +24380,20 @@ paths:
type: string
type: array
style: form
-
allowEmptyValue: true
allowReserved: false
deprecated: false
description: ''
explode: true
in: query
name: 'isPrototype[]'
required: false
schema:
items:
type: boolean
type: array
style: form
responses:
200:
content:
Expand Down Expand Up @@ -25076,6 +25102,18 @@ paths:
schema:
type: string
style: form
-
allowEmptyValue: true
allowReserved: false
deprecated: false
description: ''
explode: false
in: query
name: isPrototype
required: false
schema:
type: boolean
style: form
-
allowEmptyValue: true
allowReserved: false
Expand All @@ -25090,6 +25128,20 @@ paths:
type: string
type: array
style: form
-
allowEmptyValue: true
allowReserved: false
deprecated: false
description: ''
explode: true
in: query
name: 'isPrototype[]'
required: false
schema:
items:
type: boolean
type: array
style: form
responses:
200:
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"templated": true
},
"checklists": {
"href": "\/checklists{\/id}{?camp,camp[]}",
"href": "\/checklists{\/id}{?camp,camp[],isPrototype,isPrototype[]}",
"templated": true
},
"columnLayouts": {
Expand Down
3 changes: 2 additions & 1 deletion common/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@
},
"checklist": {
"fields": {
"name": "Name"
"name": "Name",
"copyChecklistSource": "Vorlage"
},
"name": "Checkliste | Checklisten"
},
Expand Down
3 changes: 2 additions & 1 deletion common/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@
},
"checklist": {
"fields": {
"name": "Name"
"name": "Name",
"copyChecklistSource": "Prototype"
},
"name": "Checklist | Checklists"
},
Expand Down
23 changes: 21 additions & 2 deletions frontend/src/components/checklist/ChecklistCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
path="name"
vee-rules="required"
/>

<e-select
v-model="entityData.copyChecklistSource"
path="copyChecklistSource"
:items="prototypeChecklists"
/>
</DetailPane>
</template>

Expand All @@ -50,16 +56,29 @@ export default {
},
data() {
return {
entityProperties: ['camp', 'name'],
entityProperties: ['camp', 'name', 'copyChecklistSource'],
entityUri: '',
}
},
computed: {
prototypeChecklists() {
return this.api
.get()
.checklists({ isPrototype: true })
.items.map((c) => ({
value: c._meta.self,
text: c.name,
object: c,
}))
},
},
watch: {
showDialog: function (showDialog) {
if (showDialog) {
this.setEntityData({
name: '',
camp: this.camp._meta.self,
name: '',
copyChecklistSource: null,
})
} else {
// clear form on exit
Expand Down
Loading