-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow creating event from person view (fixes #174)
- Loading branch information
1 parent
a91d50e
commit 83183e5
Showing
8 changed files
with
167 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {html} from 'lit' | ||
|
||
import './GrampsjsFormSelectType.js' | ||
import {GrampsjsObjectForm} from './GrampsjsObjectForm.js' | ||
import {GrampsjsNewEventMixin} from '../mixins/GrampsjsNewEventMixin.js' | ||
|
||
export class GrampsjsFormNewEvent extends GrampsjsNewEventMixin( | ||
GrampsjsObjectForm | ||
) { | ||
constructor() { | ||
super() | ||
this.data = {_class: 'Event'} | ||
} | ||
|
||
renderForm() { | ||
return html` | ||
${super.renderForm()} | ||
<grampsjs-form-select-type | ||
required | ||
id="event-role-type" | ||
.strings="${this.strings}" | ||
typeName="event_role_types" | ||
?loadingTypes=${this.loadingTypes} | ||
.types="${this.types}" | ||
.typesLocale="${this.typesLocale}" | ||
> | ||
</grampsjs-form-select-type> | ||
` | ||
} | ||
|
||
checkFormValidity() { | ||
const selectType = this.shadowRoot.querySelector( | ||
'grampsjs-form-select-type' | ||
) | ||
let valid = true | ||
if (!selectType !== null && !selectType.isValid()) { | ||
valid = false | ||
} | ||
const selectDate = this.shadowRoot.querySelector( | ||
'grampsjs-form-select-date' | ||
) | ||
if (!selectDate !== null && !selectDate.isValid()) { | ||
valid = false | ||
} | ||
this.isFormValid = valid | ||
} | ||
} | ||
|
||
window.customElements.define('grampsjs-form-new-event', GrampsjsFormNewEvent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import {html} from 'lit' | ||
|
||
import '@material/mwc-textfield' | ||
|
||
import '../components/GrampsjsFormSelectDate.js' | ||
import '../components/GrampsjsFormSelectObjectList.js' | ||
import '../components/GrampsjsFormSelectType.js' | ||
import '../components/GrampsjsFormPrivate.js' | ||
|
||
export const GrampsjsNewEventMixin = superClass => | ||
class extends superClass { | ||
renderForm() { | ||
return html` | ||
<pre>${JSON.stringify(this.data, null, 2)}</pre> | ||
<grampsjs-form-select-type | ||
required | ||
id="event-type" | ||
.strings="${this.strings}" | ||
?loadingTypes="${this.loadingTypes}" | ||
typeName="event_types" | ||
.types="${this.types}" | ||
.typesLocale="${this.typesLocale}" | ||
> | ||
</grampsjs-form-select-type> | ||
<h4 class="label">${this._('Date')}</h4> | ||
<p> | ||
<grampsjs-form-select-date id="date" .strings="${this.strings}"> | ||
</grampsjs-form-select-date> | ||
</p> | ||
<h4 class="label">${this._('Description')}</h4> | ||
<p> | ||
<grampsjs-form-string | ||
fullwidth | ||
id="description" | ||
@formdata:changed="${this._handleFormData}" | ||
label="${this._('Description')}" | ||
.strings="${this.strings}" | ||
> | ||
</grampsjs-form-string> | ||
</p> | ||
<h4 class="label">${this._('Place')}</h4> | ||
<grampsjs-form-select-object-list | ||
id="place" | ||
objectType="place" | ||
.strings="${this.strings}" | ||
></grampsjs-form-select-object-list> | ||
<div class="spacer"></div> | ||
<grampsjs-form-private | ||
id="private" | ||
.strings="${this.strings}" | ||
></grampsjs-form-private> | ||
` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters