Skip to content

Commit

Permalink
Use new translate mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMStraub committed Nov 2, 2021
1 parent 2a0a4d3 commit 7a4d1d9
Show file tree
Hide file tree
Showing 27 changed files with 89 additions and 241 deletions.
17 changes: 2 additions & 15 deletions src/components/GrampsjsAddMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '@material/mwc-list/mwc-list-item'
import './GrampsJsListItem.js'

import {sharedStyles} from '../SharedStyles.js'
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js'

const BASE_DIR = ''

Expand All @@ -26,7 +27,7 @@ const menuItems = [
['Media Object', '/new_media', 'photo']
]

class GrampsjsAddMenu extends LitElement {
class GrampsjsAddMenu extends GrampsjsTranslateMixin(LitElement) {
static get styles() {
return [
sharedStyles,
Expand All @@ -44,13 +45,6 @@ class GrampsjsAddMenu extends LitElement {
]
}


static get properties() {
return {
strings: {type: Object}
}
}

render() {
return html`
<div style="position: relative;">
Expand Down Expand Up @@ -84,13 +78,6 @@ class GrampsjsAddMenu extends LitElement {
menu.open = !menu.open
}

_(s) {
if (s in this.strings) {
return this.strings[s]
}
return s
}

}

window.customElements.define('grampsjs-add-menu', GrampsjsAddMenu)
12 changes: 2 additions & 10 deletions src/components/GrampsjsAppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import './GrampsjsAddMenu.js'

import {fireEvent} from '../util.js'
import {sharedStyles} from '../SharedStyles.js'
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js'

class GrampsjsAppBar extends LitElement {
class GrampsjsAppBar extends GrampsjsTranslateMixin(LitElement) {
static get styles () {
return [
sharedStyles,
Expand All @@ -39,7 +40,6 @@ class GrampsjsAppBar extends LitElement {
editMode: {type: Boolean},
editTitle: {type: String},
editDialogContent: {type: String},
strings: {type: Object},
saveButton: {type: Boolean}
}
}
Expand All @@ -50,7 +50,6 @@ class GrampsjsAppBar extends LitElement {
this.editMode = false
this.editTitle = ''
this.editDialogContent = ''
this.strings = {}
this.saveButton = false
}

Expand Down Expand Up @@ -152,13 +151,6 @@ class GrampsjsAppBar extends LitElement {
window.addEventListener('edit-mode:on', (e) => this._enableEditMode(e))
window.addEventListener('edit-mode:off', (e) => this._disableEditMode(e))
}

_ (s) {
if (s in this.strings) {
return this.strings[s]
}
return s
}
}

window.customElements.define('grampsjs-app-bar', GrampsjsAppBar)
5 changes: 2 additions & 3 deletions src/components/GrampsjsBlogPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import './GrampsJsImage.js'
import './GrampsjsGallery.js'
import './GrampsjsNoteContent.js'
import './GrampsjsTimedelta.js'
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js'

export class GrampsjsBlogPost extends LitElement {
export class GrampsjsBlogPost extends GrampsjsTranslateMixin(LitElement) {
static get styles () {
return [
sharedStyles,
Expand Down Expand Up @@ -80,15 +81,13 @@ export class GrampsjsBlogPost extends LitElement {
return {
source: {type: Object},
note: {type: Object},
strings: {type: Object}
}
}

constructor () {
super()
this.source = {}
this.note = {}
this.strings = {}
}

render () {
Expand Down
13 changes: 5 additions & 8 deletions src/components/GrampsjsBlogPreview.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import {html, css, LitElement} from 'lit'
import {html, LitElement} from 'lit'
import {sharedStyles} from '../SharedStyles.js'

import './GrampsJsImage.js'
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js'


export class GrampsjsBlogPreview extends LitElement {
export class GrampsjsBlogPreview extends GrampsjsTranslateMixin(LitElement) {
static get styles() {
return [
sharedStyles,
css`
`
sharedStyles
]
}

static get properties() {
return {
data: {type: Object},
strings: {type: Object},
data: {type: Object}
}
}

constructor() {
super()
this.data = {}
this.strings = {}
}

render() {
Expand Down
11 changes: 3 additions & 8 deletions src/components/GrampsjsFormName.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import '@material/mwc-icon-button'
import '@material/mwc-icon'

import {sharedStyles} from '../SharedStyles.js'
import {translate, fireEvent} from '../util.js'
import {fireEvent} from '../util.js'
import './GrampsjsFormString.js'
import {classMap} from 'lit/directives/class-map.js'
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js'

class GrampsjsFormName extends LitElement {
class GrampsjsFormName extends GrampsjsTranslateMixin(LitElement) {
static get styles () {
return [
sharedStyles,
Expand All @@ -34,15 +35,13 @@ class GrampsjsFormName extends LitElement {

static get properties () {
return {
strings: {type: Object},
data: {type: Object},
showMore: {type: Boolean}
}
}

constructor () {
super()
this.strings = {}
this.data = {_class: 'Name'}
this.showMore = false
}
Expand Down Expand Up @@ -129,10 +128,6 @@ class GrampsjsFormName extends LitElement {
fireEvent(this, 'formdata:changed', {data: this.data})
}

_ (s) {
return translate(this.strings, s)
}

_handleFormData (e) {
const originalTarget = e.composedPath()[0]
if (['first_name', 'call', 'nick', 'title', 'suffix'].includes(originalTarget.id)) {
Expand Down
13 changes: 2 additions & 11 deletions src/components/GrampsjsFormObjectList.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import '@material/mwc-icon-button'
import {fireEvent} from '../util.js'
import './GrampsjsSearchResultList.js'
import {sharedStyles} from '../SharedStyles.js'
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js'


class GrampsjsFormObjectList extends LitElement {
class GrampsjsFormObjectList extends GrampsjsTranslateMixin(LitElement) {
static get styles() {
return [
sharedStyles,
Expand All @@ -32,7 +33,6 @@ class GrampsjsFormObjectList extends LitElement {

static get properties() {
return {
strings: {type: Object},
objects: {type: Array},
selectedIndex: {type: Number},
reorder: {type: Boolean},
Expand All @@ -43,7 +43,6 @@ class GrampsjsFormObjectList extends LitElement {

constructor() {
super()
this.strings = {}
this.objectType = false
this.objects = []
this.selectedIndex = -1
Expand Down Expand Up @@ -159,14 +158,6 @@ class GrampsjsFormObjectList extends LitElement {
fireEvent(this, 'formdata:changed', {data: this._handleList()})
}
}

_(s) {
if (s in this.strings) {
return this.strings[s]
}
return s
}

}

window.customElements.define('grampsjs-form-object-list', GrampsjsFormObjectList)
13 changes: 2 additions & 11 deletions src/components/GrampsjsFormPrivate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {html, css, LitElement} from 'lit'
import '@material/mwc-checkbox'

import {sharedStyles} from '../SharedStyles.js'
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js'


class GrampsjsFormPrivate extends LitElement {
class GrampsjsFormPrivate extends GrampsjsTranslateMixin(LitElement) {
static get styles() {
return [
sharedStyles,
Expand All @@ -19,7 +20,6 @@ class GrampsjsFormPrivate extends LitElement {

static get properties() {
return {
strings: {type: Object},
checked: {type: Boolean},
disabled: {type: Boolean}
}
Expand All @@ -28,7 +28,6 @@ class GrampsjsFormPrivate extends LitElement {

constructor() {
super()
this.strings = {}
this.checked = false
this.disabled = false
}
Expand Down Expand Up @@ -57,14 +56,6 @@ class GrampsjsFormPrivate extends LitElement {
this.checked = e.target.checked
this.dispatchEvent(new CustomEvent('formdata:changed', {bubbles: true, composed: true, detail: {checked: this.checked}}))
}

_(s) {
if (s in this.strings) {
return this.strings[s]
}
return s
}

}

window.customElements.define('grampsjs-form-private', GrampsjsFormPrivate)
12 changes: 2 additions & 10 deletions src/components/GrampsjsFormSelectDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import '@material/mwc-list/mwc-list-item'

import {sharedStyles} from '../SharedStyles.js'
import {getSortval} from '../util.js'
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js'

const modifiers = {
0: 'Regular',
Expand Down Expand Up @@ -45,7 +46,7 @@ function parseDate (s) {
return [y, m, d]
}

class GrampsjsFormSelectDate extends LitElement {
class GrampsjsFormSelectDate extends GrampsjsTranslateMixin(LitElement) {
static get styles () {
return [
sharedStyles,
Expand All @@ -56,15 +57,13 @@ class GrampsjsFormSelectDate extends LitElement {

static get properties () {
return {
strings: {type: Object},
data: {type: Object},
disabled: {type: Boolean}
}
}

constructor () {
super()
this.strings = {}
this.data = dataDefault
this.disabled = false
}
Expand Down Expand Up @@ -185,13 +184,6 @@ class GrampsjsFormSelectDate extends LitElement {
handleChange () {
this.dispatchEvent(new CustomEvent('formdata:changed', {bubbles: true, composed: true, detail: {data: this.data}}))
}

_ (s) {
if (s in this.strings) {
return this.strings[s]
}
return s
}
}

window.customElements.define('grampsjs-form-select-date', GrampsjsFormSelectDate)
12 changes: 2 additions & 10 deletions src/components/GrampsjsFormSelectObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {sharedStyles} from '../SharedStyles.js'
import {apiGet} from '../api.js'
import {debounce, fireEvent} from '../util.js'
import './GrampsjsSearchResultList.js'
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js'

// labels for button
const btnLabel = {
Expand All @@ -26,7 +27,7 @@ const btnLabel = {
note: 'Select an existing note'
}

class GrampsjsFormSelectObject extends LitElement {
class GrampsjsFormSelectObject extends GrampsjsTranslateMixin(LitElement) {
static get styles () {
return [
sharedStyles,
Expand All @@ -48,7 +49,6 @@ class GrampsjsFormSelectObject extends LitElement {

static get properties () {
return {
strings: {type: Object},
objectType: {type: String},
objects: {type: Array},
data: {type: Array},
Expand All @@ -61,7 +61,6 @@ class GrampsjsFormSelectObject extends LitElement {

constructor () {
super()
this.strings = {}
this.objectType = ''
this.objects = []
this.data = []
Expand Down Expand Up @@ -182,13 +181,6 @@ class GrampsjsFormSelectObject extends LitElement {
_clearBox () {
this.shadowRoot.getElementById('textfield').value = ''
}

_ (s) {
if (s in this.strings) {
return this.strings[s]
}
return s
}
}

window.customElements.define('grampsjs-form-select-object', GrampsjsFormSelectObject)
5 changes: 2 additions & 3 deletions src/components/GrampsjsFormSelectObjectList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {html, LitElement} from 'lit'
import {sharedStyles} from '../SharedStyles.js'
import './GrampsjsFormSelectObject.js'
import './GrampsjsFormObjectList.js'
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js'


class GrampsjsFormSelectObjectList extends LitElement {
class GrampsjsFormSelectObjectList extends GrampsjsTranslateMixin(LitElement) {
static get styles() {
return [
sharedStyles
Expand All @@ -18,7 +19,6 @@ class GrampsjsFormSelectObjectList extends LitElement {

static get properties() {
return {
strings: {type: Object},
objectType: {type: String},
label: {type: String},
multiple: {type: Boolean},
Expand All @@ -29,7 +29,6 @@ class GrampsjsFormSelectObjectList extends LitElement {

constructor() {
super()
this.strings = {}
this.objectType = ''
this.label = ''
this.multiple = false
Expand Down
Loading

0 comments on commit 7a4d1d9

Please sign in to comment.