Skip to content

Commit 7476b26

Browse files
loivseniOvergaard
authored andcommitted
member type property options
1 parent be4648e commit 7476b26

File tree

4 files changed

+78
-4
lines changed

4 files changed

+78
-4
lines changed

src/packages/core/content-type/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ export interface UmbPropertyTypeModel {
4444
variesBySegment: boolean;
4545
validation: UmbPropertyTypeValidationModel;
4646
appearance: UmbPropertyTypeAppearanceModel;
47+
visibility?: UmbPropertyTypeVisibilityModel;
48+
isSensitive?: boolean;
49+
}
50+
51+
export interface UmbPropertyTypeVisibilityModel {
52+
memberCanEdit: boolean;
53+
memberCanView: boolean;
4754
}
4855

4956
export interface UmbPropertyTypeValidationModel {

src/packages/core/content-type/workspace/views/design/content-type-design-editor-property.element.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,21 @@ export class UmbContentTypeDesignEditorPropertyElement extends UmbLitElement {
312312
<span>* ${this.localize.term('general_mandatory')}</span>
313313
</uui-tag>`
314314
: nothing}
315+
${this.property.visibility?.memberCanView === true
316+
? html`<uui-tag look="default">
317+
<uui-icon name="icon-eye"></uui-icon> ${this.localize.term('contentTypeEditor_showOnMemberProfile')}
318+
</uui-tag>`
319+
: nothing}
320+
${this.property.visibility?.memberCanEdit === true
321+
? html`<uui-tag look="default">
322+
<uui-icon name="icon-edit"></uui-icon> ${this.localize.term('contentTypeEditor_memberCanEdit')}
323+
</uui-tag>`
324+
: nothing}
325+
${this.property.isSensitive === true
326+
? html`<uui-tag look="default">
327+
<uui-icon name="icon-lock"></uui-icon> ${this.localize.term('contentTypeEditor_isSensitiveData')}
328+
</uui-tag>`
329+
: nothing}
315330
</div>`
316331
: nothing;
317332
}
@@ -433,6 +448,7 @@ export class UmbContentTypeDesignEditorPropertyElement extends UmbLitElement {
433448
.types > div uui-icon,
434449
.inherited uui-icon {
435450
vertical-align: sub;
451+
margin-right: var(--uui-size-space-1);
436452
}
437453
438454
.inherited {
@@ -446,6 +462,7 @@ export class UmbContentTypeDesignEditorPropertyElement extends UmbLitElement {
446462
top: var(--uui-size-space-2);
447463
left: var(--uui-size-space-2);
448464
display: flex;
465+
flex-flow: wrap;
449466
gap: var(--uui-size-space-2);
450467
}
451468

src/packages/core/property-type/workspace/views/settings/property-workspace-view-settings.element.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ export class UmbPropertyTypeWorkspaceViewSettingsElement extends UmbLitElement i
6161
@query('#alias-input')
6262
private _aliasInput!: UUIInputLockElement;
6363

64+
@state()
65+
private _entityType?: string;
66+
6467
constructor() {
6568
super();
6669

@@ -82,6 +85,7 @@ export class UmbPropertyTypeWorkspaceViewSettingsElement extends UmbLitElement i
8285
this.consumeContext(UMB_CONTENT_TYPE_WORKSPACE_CONTEXT, (instance) => {
8386
this.observe(instance.variesByCulture, (variesByCulture) => (this._contentTypeVariesByCulture = variesByCulture));
8487
this.observe(instance.variesBySegment, (variesBySegment) => (this._contentTypeVariesBySegment = variesBySegment));
88+
this._entityType = instance.getEntityType();
8589
}).passContextAliasMatches();
8690
}
8791

@@ -142,6 +146,20 @@ export class UmbPropertyTypeWorkspaceViewSettingsElement extends UmbLitElement i
142146
});
143147
}
144148

149+
#onToggleShowOnMemberProfile(e: UUIBooleanInputEvent) {
150+
const memberCanEdit = this._data?.visibility?.memberCanEdit ?? false;
151+
this.updateValue({ visibility: { memberCanView: e.target.checked, memberCanEdit } });
152+
}
153+
154+
#onToggleMemberCanEdit(e: UUIBooleanInputEvent) {
155+
const memberCanView = this._data?.visibility?.memberCanView ?? false;
156+
this.updateValue({ visibility: { memberCanEdit: e.target.checked, memberCanView } });
157+
}
158+
159+
#onToggleIsSensitiveData(e: UUIBooleanInputEvent) {
160+
this.updateValue({ isSensitive: e.target.checked });
161+
}
162+
145163
#onToggleAliasLock() {
146164
this._aliasLocked = !this._aliasLocked;
147165
if (this._aliasLocked && !this._data?.alias) {
@@ -255,10 +273,40 @@ export class UmbPropertyTypeWorkspaceViewSettingsElement extends UmbLitElement i
255273
</b>
256274
<div id="appearances">${this.#renderAlignLeftIcon()} ${this.#renderAlignTopIcon()}</div>
257275
</div>
276+
${this.#renderMemberTypeOptions()}
258277
</uui-box>
259278
`;
260279
}
261280

281+
#renderMemberTypeOptions() {
282+
if (this._entityType !== 'member-type') return nothing;
283+
return html` <hr />
284+
<div class="container">
285+
<b style="margin-bottom: var(--uui-size-space-3)">
286+
<umb-localize key="general_options">Options</umb-localize>
287+
</b>
288+
<div>
289+
<uui-toggle
290+
?checked=${this._data?.visibility?.memberCanView}
291+
@change=${this.#onToggleShowOnMemberProfile}
292+
label=${this.localize.term('contentTypeEditor_showOnMemberProfile')}></uui-toggle>
293+
<div>${this.localize.term('contentTypeEditor_showOnMemberProfileDescription')}</div>
294+
295+
<uui-toggle
296+
?checked=${this._data?.visibility?.memberCanEdit}
297+
@change=${this.#onToggleMemberCanEdit}
298+
label=${this.localize.term('contentTypeEditor_memberCanEdit')}></uui-toggle>
299+
<div>${this.localize.term('contentTypeEditor_memberCanEditDescription')}</div>
300+
301+
<uui-toggle
302+
?checked=${this._data?.isSensitive}
303+
@change=${this.#onToggleIsSensitiveData}
304+
label=${this.localize.term('contentTypeEditor_isSensitiveData')}></uui-toggle>
305+
<div>${this.localize.term('contentTypeEditor_isSensitiveDataDescription')}</div>
306+
</div>
307+
</div>`;
308+
}
309+
262310
#renderAlignLeftIcon() {
263311
return html`<button
264312
type="button"

src/packages/members/member-type/repository/detail/member-type-detail.server.data-source.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ export class UmbMemberTypeServerDataSource implements UmbDetailDataSource<UmbMem
9797
variesBySegment: property.variesBySegment,
9898
validation: property.validation,
9999
appearance: property.appearance,
100+
visibility: property.visibility,
101+
isSensitive: property.isSensitive,
100102
};
101103
}),
102104
containers: data.containers.map((container) => {
@@ -146,8 +148,8 @@ export class UmbMemberTypeServerDataSource implements UmbDetailDataSource<UmbMem
146148
container: property.container ? { id: property.container.id } : null,
147149
sortOrder: property.sortOrder,
148150
alias: property.alias,
149-
isSensitive: false,
150-
visibility: { memberCanEdit: true, memberCanView: true },
151+
isSensitive: property.isSensitive ?? false,
152+
visibility: property.visibility ?? { memberCanEdit: false, memberCanView: false },
151153
name: property.name,
152154
description: property.description,
153155
dataType: { id: property.dataType.unique },
@@ -206,8 +208,8 @@ export class UmbMemberTypeServerDataSource implements UmbDetailDataSource<UmbMem
206208
id: property.id,
207209
container: property.container ? { id: property.container.id } : null,
208210
sortOrder: property.sortOrder,
209-
isSensitive: false,
210-
visibility: { memberCanEdit: true, memberCanView: true },
211+
isSensitive: property.isSensitive ?? false,
212+
visibility: property.visibility ?? { memberCanEdit: false, memberCanView: false },
211213
alias: property.alias,
212214
name: property.name,
213215
description: property.description,

0 commit comments

Comments
 (0)