Skip to content

Commit

Permalink
Fix editing source attributes (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMStraub authored Jul 6, 2024
1 parent 9be3ee7 commit b7559f6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/components/GrampsjsAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import '@material/mwc-list/mwc-list-item'
import {fireEvent} from '../util.js'

export class GrampsjsAttributes extends GrampsjsEditableList {
static get properties() {
return {
source: {type: Boolean},
}
}

constructor() {
super()
this.source = false
}

row(obj) {
return html`
<mwc-list-item
Expand All @@ -28,6 +39,7 @@ export class GrampsjsAttributes extends GrampsjsEditableList {
_handleAdd() {
this.dialogContent = html`
<grampsjs-form-edit-attribute
?source="${this.source}"
new
@object:save="${this._handleAttrSave}"
@object:cancel="${this._handleAttrCancel}"
Expand All @@ -40,11 +52,15 @@ export class GrampsjsAttributes extends GrampsjsEditableList {
_handleEdit() {
const attr = this.data[this._selectedIndex]
const data = {
type: {_class: 'AttributeType', string: attr.type || ''},
type: {
_class: this.source ? 'SrcAttributeType' : 'AttributeType',
string: attr.type || '',
},
value: attr.value || '',
}
this.dialogContent = html`
<grampsjs-form-edit-attribute
?source="${this.source}"
@object:save="${this._handleAttrSaveEdit}"
@object:cancel="${this._handleAttrCancel}"
.strings="${this.strings}"
Expand Down
13 changes: 12 additions & 1 deletion src/components/GrampsjsFormEditAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@ import './GrampsjsFormSelectType.js'
import {GrampsjsObjectForm} from './GrampsjsObjectForm.js'

class GrampsjsFormEditAttribute extends GrampsjsObjectForm {
static get properties() {
return {
source: {type: Boolean},
}
}

constructor() {
super()
this.source = false
}

renderForm() {
return html`
<grampsjs-form-select-type
required
id="attrtype"
id="${this.source ? 'srcattrtype' : 'attrtype'}"
heading="${this._('Type')}"
.strings="${this.strings}"
typeName="attribute_types"
Expand Down
1 change: 1 addition & 0 deletions src/components/GrampsjsObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ export class GrampsjsObject extends GrampsjsTranslateMixin(LitElement) {
.strings=${this.strings}
?edit="${this.edit}"
.data=${this.data.attribute_list}
?source="${this._objectsName === 'Sources'}"
></grampsjs-attributes>`
case 'addresses':
return html`<grampsjs-addresses
Expand Down
6 changes: 6 additions & 0 deletions src/components/GrampsjsObjectForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ export class GrampsjsObjectForm extends GrampsjsTranslateMixin(LitElement) {
if (originalTarget.id === 'name') {
this.data = e.detail.data
}
if (originalTarget.id === 'srcattrtype') {
this.data = {
...this.data,
type: {_class: 'SrcAttributeType', string: e.detail.data},
}
}
if (originalTarget.id === 'attrtype') {
this.data = {
...this.data,
Expand Down

0 comments on commit b7559f6

Please sign in to comment.