Allow creating places and sources from more selectors (#1517)

Enable inline creation on the place selector of the New Event dialog
and view, the place selector of the event details and place reference
dialogs, and the source selector of the citation details dialog.

The Enclosed By selector of the New Place view allows it too, but not
when the New Place form is itself the create dialog of an object
selector, so that inline creation stays one dialog deep.

Part of #1183.
This commit is contained in:
David Straub
2026-10-11 09:08:17 +02:00
committed by GitHub
parent c5e7ab96c8
commit 50929be6f7
7 changed files with 22 additions and 0 deletions
@@ -31,6 +31,7 @@ class GrampsjsFormEditCitationDetails extends GrampsjsObjectForm {
<grampsjs-form-select-object-list <grampsjs-form-select-object-list
id="source" id="source"
objectType="source" objectType="source"
allowNew
.objectsInitial="${this.data.source_handle .objectsInitial="${this.data.source_handle
? [ ? [
{ {
@@ -41,6 +41,7 @@ class GrampsjsFormEditEventDetails extends GrampsjsObjectForm {
fixedMenuPosition fixedMenuPosition
style="min-height: 300px;" style="min-height: 300px;"
objectType="place" objectType="place"
allowNew
.appState="${this.appState}" .appState="${this.appState}"
id="place" id="place"
label="${this._('Select')}" label="${this._('Select')}"
+1
View File
@@ -29,6 +29,7 @@ class GrampsjsFormPlaceRef extends GrampsjsObjectForm {
notDeletable notDeletable
style="min-height: 300px;" style="min-height: 300px;"
objectType="place" objectType="place"
allowNew
.objectsInitial="${this.data.ref .objectsInitial="${this.data.ref
? [ ? [
{ {
+1
View File
@@ -47,6 +47,7 @@ export const GrampsjsNewEventMixin = superClass =>
fixedMenuPosition fixedMenuPosition
id="place" id="place"
objectType="place" objectType="place"
allowNew
.appState="${this.appState}" .appState="${this.appState}"
></grampsjs-form-select-object-list> ></grampsjs-form-select-object-list>
+4
View File
@@ -24,6 +24,9 @@ export const GrampsjsNewPlaceMixin = superClass =>
super() super()
this.data = {_class: 'Place'} this.data = {_class: 'Place'}
this._latLongDialogOpen = false this._latLongDialogOpen = false
// Off in the create dialog of an object selector, so that inline
// creation stays one dialog deep.
this.allowNewEnclosedBy = false
} }
renderForm() { renderForm() {
@@ -58,6 +61,7 @@ export const GrampsjsNewPlaceMixin = superClass =>
id="enclosed" id="enclosed"
multiple multiple
objectType="place" objectType="place"
?allowNew="${this.allowNewEnclosedBy}"
.appState="${this.appState}" .appState="${this.appState}"
></grampsjs-form-select-object-list> ></grampsjs-form-select-object-list>
+1
View File
@@ -11,6 +11,7 @@ export class GrampsjsViewNewPlace extends GrampsjsNewPlaceMixin(
this.postUrl = '/api/places/' this.postUrl = '/api/places/'
this.itemPath = 'place' this.itemPath = 'place'
this.objClass = 'Place' this.objClass = 'Place'
this.allowNewEnclosedBy = true
} }
renderContent() { renderContent() {
+13
View File
@@ -0,0 +1,13 @@
import {describe, it, expect} from 'vitest'
import {GrampsjsFormNewPlace} from '../../src/components/GrampsjsFormNewPlace.js'
import {GrampsjsViewNewPlace} from '../../src/views/GrampsjsViewNewPlace.js'
describe('new place: creating the enclosing place', () => {
it('is offered in the New Place view', () => {
expect(new GrampsjsViewNewPlace().allowNewEnclosedBy).toBe(true)
})
it('is not offered in the create dialog of an object selector', () => {
expect(new GrampsjsFormNewPlace().allowNewEnclosedBy).toBe(false)
})
})