Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/dt-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class DtBase extends LitElement {
`,
];
}

static get properties() {
return {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DtMultiSelect } from '../dt-multi-select/dt-multi-select.js';
import './dt-church-health-circle-icon.js';
import '../dt-toggle/dt-toggle.js';


export class DtChurchHealthCircle extends DtMultiSelect {
static get styles() {
return [
Expand Down Expand Up @@ -63,6 +64,9 @@ export class DtChurchHealthCircle extends DtMultiSelect {
.health-circle--disabled dt-church-health-icon {
cursor: not-allowed;
}
.health-circle--readonly dt-church-health-icon {
cursor: not-allowed;
}

dt-church-health-icon {
position: absolute;
Expand All @@ -81,6 +85,12 @@ export class DtChurchHealthCircle extends DtMultiSelect {
transform: rotate(var(--az)) translate(var(--radius))
rotate(calc(-1 * var(--az)));
}

.corner-button{
position: absolute;
top: 0;
right: 0;
}
`,
css`
dt-toggle::part(root) {
Expand Down Expand Up @@ -170,6 +180,7 @@ export class DtChurchHealthCircle extends DtMultiSelect {
'health-circle': true,
'health-circle--committed': this.isCommited,
'health-circle--disabled': this.disabled,
'health-circle--readonly': this.readonly,
})}
>
<div class="health-circle__grid">
Expand All @@ -181,7 +192,7 @@ export class DtChurchHealthCircle extends DtMultiSelect {
.active=${(this.value || []).indexOf(key) !== -1}
.style="--i: ${index + 1}"
.missingIcon="${this.missingIcon}"
?disabled=${this.disabled}
?disabled=${this.disabled || this.readonly}
data-value="${key}"
@change="${this.handleIconClick}"
>
Expand All @@ -191,7 +202,9 @@ export class DtChurchHealthCircle extends DtMultiSelect {
${this.renderIconLoading()} ${this.renderIconSaved()}
</div>
</div>


${!this.readonly
? html`
<dt-toggle
name="church_commitment"
label="${this.options?.church_commitment?.label}"
Expand All @@ -200,9 +213,26 @@ export class DtChurchHealthCircle extends DtMultiSelect {
?checked=${this.isCommited}
data-value="church_commitment"
>
</dt-toggle>
</dt-toggle>`
:
null}
${this.renderError()}
</div>
${this.readonly && !this.disabled
? html`
<div class="corner-button">
<button
@click="${this.switchReadOnly}"
@keydown="${this._inputKeyDown}"
@blur="${this._handleButtonBlur}"
class="readonly-btn"
id="add-item"
type="button"
tabindex="1"
>
<dt-icon icon="mdi:pencil"></dt-icon>
</button>
</div>`:null}
`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ export default {
error: '',
onChange: action('on-change'),
},
render: args => {
return html`
render: args => html`
<div style="width: ${ifDefined(args.width)}px;">
<dt-church-health-circle
name="${ifDefined(args.name)}"
.value="${args.value}"
.options="${args.options}"
missingIcon="${ifDefined(args.missingIcon)}"
?disabled=${args.disabled}
?readonly=${args.readonly}
?loading="${args.loading}"
?saved="${args.saved}"
error="${ifDefined(args.error)}"
Expand All @@ -173,8 +173,7 @@ export default {
${args.slot}
</dt-church-health-circle>
</div>
`;
},
`,
};

export const Empty = {};
Expand Down Expand Up @@ -222,6 +221,13 @@ export const Disabled = {
},
};

export const ReadOnly = {
args: {
value: ['church_bible'],
readonly: true,
},
};

export const PrivateField = {
args: {
private: true,
Expand Down Expand Up @@ -288,11 +294,11 @@ export const ApiSettings = {
],
settings: null,
},
};*/
}; */
/*
export const ApiGroup = {
args: {
groupId: 3,
group: null,
},
};*/
}; */
18 changes: 15 additions & 3 deletions src/components/form/dt-connection/dt-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ export class DtConnection extends DtTags {
.filter(i => !i.delete)
.map(
opt => html`
${!this.readonly
? html`
<div
class="selected-option"
@click="${this._handleItemClick}"
Expand All @@ -239,7 +241,11 @@ export class DtConnection extends DtTags {
>
x
</button>
</div>
</div>`
:
html`<div>
${opt.label}
</div>`}
`,
);
}
Expand Down Expand Up @@ -281,10 +287,12 @@ export class DtConnection extends DtTags {
}

render() {
const optionListStyles = this.optionListStyles;
const {optionListStyles} = this;
return html`
${this.labelTemplate()}

${!this.readonly
? html`
<div
class="input-group ${this.disabled ? 'disabled' : ''} ${this.allowAdd
? 'allowAdd'
Expand Down Expand Up @@ -319,7 +327,11 @@ export class DtConnection extends DtTags {
${this._renderOptions()}
</ul>
${this.renderIcons()}
</div>
</div>`
:
html`<div class="readonly-options">
${this._renderSelectedOptions()}
</div>`}
`;
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/components/form/dt-connection/dt-connection.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export default {
placeholder,
value,
disabled,
readonly,
required,
requiredMessage,
icon,
Expand All @@ -160,6 +161,7 @@ export default {
.options="${options}"
.value="${value}"
?disabled=${disabled}
?readonly=${readonly}
?required=${required}
requiredMessage="${ifDefined(requiredMessage)}"
icon="${ifDefined(icon)}"
Expand Down Expand Up @@ -277,6 +279,21 @@ export const Disabled = {
disabled: true,
},
};
export const ReadOnly = {
args: {
value: [basicOptions[1],
{
id: 2,
label: 'test',
},
{
id: 3,
label: 'WeeWoo',
}],
options: basicOptions,
readonly: true,
},
};
export const PrivateField = {
args: {
private: true,
Expand Down
15 changes: 14 additions & 1 deletion src/components/form/dt-date/dt-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export class DtDate extends DtFormBase {
};
return classes;
}

get fieldContainerClasses() {
return {
'field-container': true,
Expand All @@ -232,9 +233,17 @@ export class DtDate extends DtFormBase {
this.timestamp = new Date(this.value).getTime();
}

let readonlyValue = this.value;
if (this.value) {
const [y, m, d] = this.value.split('-');
readonlyValue = `${m}/${d}/${y}`;
}

return html`
${this.labelTemplate()}

${!this.readonly
? html`
<div class="input-group">
<div class="${classMap(this.fieldContainerClasses)}">
<input
Expand Down Expand Up @@ -265,7 +274,11 @@ export class DtDate extends DtFormBase {
</div>

${this.renderIcons()}
</div>
</div>`
:
html`<div class="readonly-options">
${readonlyValue}
</div>`}
`;
}

Expand Down
9 changes: 9 additions & 0 deletions src/components/form/dt-date/dt-date.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default {
value = '',
timestamp,
disabled = false,
readonly = false,
required = false,
requiredMessage,
icon = 'https://cdn-icons-png.flaticon.com/512/1077/1077114.png',
Expand All @@ -64,6 +65,7 @@ export default {
value=${ifDefined(value)}
timestamp=${ifDefined(timestamp)}
?disabled=${disabled}
?readonly=${readonly}
?required=${required}
requiredMessage=${ifDefined(requiredMessage)}
icon=${ifDefined(icon)}
Expand Down Expand Up @@ -121,6 +123,13 @@ export const Disabled = {
},
};

export const ReadOnly = {
args: {
value: '2020-01-01',
readonly: true,
},
};

export const PrivateField = {
args: {
private: true,
Expand Down
21 changes: 20 additions & 1 deletion src/components/form/dt-datetime/dt-datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,24 @@ export class DtDatetime extends DtDate {
this.timestamp = new Date(this.value).getTime();
}

let readonlyValue = this.value;
if (this.value) {
const dateObj = new Date(this.value);
readonlyValue = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
hour12: true
}).format(dateObj);
}

return html`
${this.labelTemplate()}

${!this.readonly
? html`
<div class="input-group">
<div class="${classMap(this.fieldContainerClasses)}">
<input
Expand Down Expand Up @@ -68,7 +83,11 @@ export class DtDatetime extends DtDate {
</div>

${this.renderIcons()}
</div>
</div>`
:
html`<div class="readonly-options">
${readonlyValue}
</div>`}
`;
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/components/form/dt-datetime/dt-datetime.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default {
value = '',
timestamp,
disabled = false,
readonly = false,
required = false,
requiredMessage,
icon = 'https://cdn-icons-png.flaticon.com/512/1077/1077114.png',
Expand All @@ -64,6 +65,7 @@ export default {
value=${ifDefined(value)}
timestamp=${ifDefined(timestamp)}
?disabled=${disabled}
?readonly=${readonly}
?required=${required}
requiredMessage=${ifDefined(requiredMessage)}
icon=${ifDefined(icon)}
Expand Down Expand Up @@ -121,6 +123,13 @@ export const Disabled = {
},
};

export const ReadOnly = {
args: {
value: '2023-07-21T17:00',
readonly: true,
},
};

export const PrivateField = {
args: {
private: true,
Expand Down
Loading
Loading