Skip to content

Commit

Permalink
Allow adding citation when creating new objects
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMStraub committed Jan 5, 2024
1 parent 0bb00cd commit e6323ac
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/mixins/GrampsjsNewEventMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const GrampsjsNewEventMixin = superClass =>
.strings="${this.strings}"
></grampsjs-form-select-object-list>
${this._renderCitationForm()}
<div class="spacer"></div>
<grampsjs-form-private
id="private"
Expand Down
1 change: 1 addition & 0 deletions src/views/GrampsjsViewNewEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class GrampsjsViewNewEvent extends GrampsjsNewEventMixin(
}

_handleFormData(e) {
super._handleFormData(e)
this.checkFormValidity()
const originalTarget = e.composedPath()[0]
if (originalTarget.id === 'event-type') {
Expand Down
2 changes: 2 additions & 0 deletions src/views/GrampsjsViewNewFamily.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export class GrampsjsViewNewFamily extends GrampsjsViewNewObject {
>
</grampsjs-form-select-type>
${this._renderCitationForm()}
<div class="spacer"></div>
<grampsjs-form-private
id="private"
Expand Down
21 changes: 20 additions & 1 deletion src/views/GrampsjsViewNewObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ export class GrampsjsViewNewObject extends GrampsjsView {
`
}

_renderCitationForm() {
return html`
<h4 class="label">${this._('Citation')}</h4>
<grampsjs-form-select-object-list
multiple
id="object-citation"
objectType="citation"
.strings="${this.strings}"
></grampsjs-form-select-object-list>
`
}

_updateData() {
this.loading = true
this.loadingTypes = true
Expand Down Expand Up @@ -206,11 +219,17 @@ export class GrampsjsViewNewObject extends GrampsjsView {
this.data = {...this.data, private: e.detail.checked}
}
if (
['author', 'pubinfo', 'abbrev', 'page', 'desc'].includes(
['author', 'pubinfo', 'abbrev', 'page', 'desc', 'description'].includes(
originalTarget.id
)
) {
this.data = {...this.data, [originalTarget.id]: e.detail.data}
}
if (originalTarget.id === 'object-citation-list') {
this.data = {
...this.data,
citation_list: e.detail.data ?? [],
}
}
}
}
8 changes: 7 additions & 1 deletion src/views/GrampsjsViewNewPerson.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const gender = {
0: 'Female',
}

const dataDefault = {_class: 'Person', gender: 2}
const dataDefault = {_class: 'Person', gender: 2, citation_list: []}

export class GrampsjsViewNewPerson extends GrampsjsViewNewObject {
constructor() {
Expand Down Expand Up @@ -80,6 +80,8 @@ export class GrampsjsViewNewPerson extends GrampsjsViewNewObject {
.strings="${this.strings}"
></grampsjs-form-select-object-list>
${this._renderCitationForm()}
<div class="spacer"></div>
<grampsjs-form-private
id="private"
Expand Down Expand Up @@ -153,6 +155,7 @@ export class GrampsjsViewNewPerson extends GrampsjsViewNewObject {
_class: 'Event',
handle: handleBirth,
type: {_class: 'EventType', string: birthString},
citation_list: person.citation_list ?? [],
},
]
}
Expand All @@ -169,6 +172,7 @@ export class GrampsjsViewNewPerson extends GrampsjsViewNewObject {
_class: 'Event',
handle: handleDeath,
type: {_class: 'EventType', string: deathString},
citation_list: person.citation_list ?? [],
},
]
}
Expand All @@ -188,12 +192,14 @@ export class GrampsjsViewNewPerson extends GrampsjsViewNewObject {
_class: 'Event',
handle: handleBirth,
type: {_class: 'EventType', string: birthString},
citation_list: person.citation_list ?? [],
},
{
...death,
_class: 'Event',
handle: handleDeath,
type: {_class: 'EventType', string: deathString},
citation_list: person.citation_list ?? [],
},
]
}
Expand Down
2 changes: 2 additions & 0 deletions src/views/GrampsjsViewNewPlace.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export class GrampsjsViewNewPlace extends GrampsjsViewNewObject {
.strings="${this.strings}"
></grampsjs-form-select-object-list>
${this._renderCitationForm()}
<div class="spacer"></div>
<grampsjs-form-private
id="private"
Expand Down

0 comments on commit e6323ac

Please sign in to comment.