a few more corrections of key to id

This commit is contained in:
Niels Lyngsø
2023-04-04 14:13:03 +02:00
parent 2844a9b600
commit 77ac938b77
26 changed files with 86 additions and 89 deletions

View File

@@ -49,13 +49,13 @@ export class UmbDocumentTypeWorkspaceViewTemplatesElement extends UmbLitElement
if (!this._workspaceContext) return;
}
async #changeDefaultKey(e: CustomEvent) {
// save new default key
console.log('workspace: default template key', e);
async #changeDefaultId(e: CustomEvent) {
// save new default id
console.log('workspace: default template id', e);
}
#changeAllowedKeys(e: CustomEvent) {
// save new allowed keys
// save new allowed ids
console.log('workspace: allowed templates changed', e);
}
@@ -67,7 +67,7 @@ export class UmbDocumentTypeWorkspaceViewTemplatesElement extends UmbLitElement
<umb-input-template-picker
.defaultKey="${/*this._documentType?.defaultTemplateId ??*/ ''}"
.allowedKeys="${/*this._documentType?.allowedTemplateIds ??*/ []}"
@change-default="${this.#changeDefaultKey}"
@change-default="${this.#changeDefaultId}"
@change-allowed="${this.#changeAllowedKeys}"></umb-input-template-picker>
</div>
</umb-workspace-property-layout>

View File

@@ -28,7 +28,7 @@ export class UmbDataTypeFolderServerDataSource implements UmbFolderDataSource {
}
/**
* Creates a Data Type folder with the given key from the server
* Creates a Data Type folder with the given id from the server
* @param {string} parentId
* @return {*}
* @memberof UmbDataTypeFolderServerDataSource
@@ -45,7 +45,7 @@ export class UmbDataTypeFolderServerDataSource implements UmbFolderDataSource {
}
/**
* Fetches a Data Type folder with the given key from the server
* Fetches a Data Type folder with the given id from the server
* @param {string} id
* @return {*}
* @memberof UmbDataTypeFolderServerDataSource
@@ -95,7 +95,7 @@ export class UmbDataTypeFolderServerDataSource implements UmbFolderDataSource {
}
/**
* Deletes a Data Type folder with the given key on the server
* Deletes a Data Type folder with the given id on the server
* @param {string} id
* @return {*}
* @memberof UmbDataTypeServerDataSource

View File

@@ -32,7 +32,7 @@ export class UmbDataTypeServerDataSource
}
/**
* Fetches a Data Type with the given key from the server
* Fetches a Data Type with the given id from the server
* @param {string} id
* @return {*}
* @memberof UmbDataTypeServerDataSource
@@ -71,7 +71,7 @@ export class UmbDataTypeServerDataSource
*/
async insert(dataType: CreateDataTypeRequestModel & { id: string }) {
if (!dataType) throw new Error('Data Type is missing');
if (!dataType.id) throw new Error('Data Type key is missing');
if (!dataType.id) throw new Error('Data Type id is missing');
tryExecuteAndNotify(
this.#host,

View File

@@ -31,7 +31,7 @@ export class UmbDataTypeTreeServerDataSource implements UmbTreeDataSource {
}
/**
* Fetches the children of a given parent key from the server
* Fetches the children of a given parent id from the server
* @param {(string | null)} parentId
* @return {*}
* @memberof UmbDataTypeTreeServerDataSource
@@ -48,8 +48,8 @@ export class UmbDataTypeTreeServerDataSource implements UmbTreeDataSource {
}
/**
* Fetches the items for the given keys from the server
* @param {Array<string>} keys
* Fetches the items for the given ids from the server
* @param {Array<string>} ids
* @return {*}
* @memberof UmbDataTypeTreeServerDataSource
*/

View File

@@ -3,5 +3,5 @@ import { EntityTreeItemResponseModel, PagedEntityTreeItemResponseModel } from '@
export interface RelationTypeTreeDataSource {
getRootItems(): Promise<DataSourceResponse<PagedEntityTreeItemResponseModel>>;
getItems(key: Array<string>): Promise<DataSourceResponse<EntityTreeItemResponseModel[]>>;
getItems(ids: Array<string>): Promise<DataSourceResponse<EntityTreeItemResponseModel[]>>;
}

View File

@@ -65,7 +65,7 @@ export class RelationTypeTreeServerDataSource implements RelationTypeTreeDataSou
}
/**
* Fetches the items for the given keys from the server
* Fetches the items for the given ids from the server
* @param {Array<string>} ids
* @return {*}
* @memberof RelationTypeTreeServerDataSource

View File

@@ -156,12 +156,12 @@ export class UmbCollectionContext<DataType extends EntityTreeItemResponseModel =
this.#selection.next([]);
}
public select(key: string) {
this.#selection.appendOne(key);
public select(id: string) {
this.#selection.appendOne(id);
}
public deselect(key: string) {
this.#selection.filter((k) => k !== key);
public deselect(id: string) {
this.#selection.filter((k) => k !== id);
}
// TODO: how can we make sure to call this.

View File

@@ -125,7 +125,7 @@ export class UmbInputDocumentPickerElement extends FormControlMixin(UmbLitElemen
}
private _openPicker() {
// We send a shallow copy(good enough as its just an array of keys) of our this._selectedIds, as we don't want the modal to manipulate our data:
// We send a shallow copy(good enough as its just an array of ids) of our this._selectedIds, as we don't want the modal to manipulate our data:
const modalHandler = this._modalContext?.open(UMB_DOCUMENT_PICKER_MODAL, {
multiple: this.max === 1 ? false : true,
selection: [...this._selectedIds],

View File

@@ -80,7 +80,7 @@ export class UmbInputDocumentTypePickerElement extends FormControlMixin(UmbLitEl
}
private _openPicker() {
// We send a shallow copy(good enough as its just an array of keys) of our this._selectedIds, as we don't want the modal to manipulate our data:
// We send a shallow copy(good enough as its just an array of ids) of our this._selectedIds, as we don't want the modal to manipulate our data:
const modalHandler = this._modalContext?.open(UMB_DOCUMENT_TYPE_PICKER_MODAL, {
multiple: true,
selection: [...this._selectedIds],

View File

@@ -68,16 +68,16 @@ export class UmbInputLanguagePickerElement extends FormControlMixin(UmbLitElemen
public get selectedIsoCodes(): Array<string> {
return this._selectedIsoCodes;
}
public set selectedIsoCodes(keys: Array<string>) {
this._selectedIsoCodes = keys;
super.value = keys.join(',');
public set selectedIsoCodes(isoCodes: Array<string>) {
this._selectedIsoCodes = isoCodes;
super.value = isoCodes.join(',');
this._observePickedItems();
}
@property()
public set value(keysString: string) {
if (keysString !== this._value) {
this.selectedIsoCodes = keysString.split(/[ ,]+/);
public set value(isoCodesString: string) {
if (isoCodesString !== this._value) {
this.selectedIsoCodes = isoCodesString.split(/[ ,]+/);
}
}

View File

@@ -51,8 +51,8 @@ export class UmbInputListBaseElement extends UmbLitElement {
});
}
protected removeFromSelection(key: string) {
this.value = this.value.filter((k) => k !== key);
protected removeFromSelection(id: string) {
this.value = this.value.filter((k) => k !== id);
this.selectionUpdated();
}

View File

@@ -139,7 +139,7 @@ export class UmbInputMediaPickerElement extends FormControlMixin(UmbLitElement)
}
private _openPicker() {
// We send a shallow copy(good enough as its just an array of keys) of our this._selectedIds, as we don't want the modal to manipulate our data:
// We send a shallow copy(good enough as its just an array of ids) of our this._selectedIds, as we don't want the modal to manipulate our data:
const modalHandler = this._modalContext?.open(UMB_MEDIA_PICKER_MODAL, {
multiple: this.max === 1 ? false : true,
selection: [...this._selectedIds],

View File

@@ -5,24 +5,19 @@ import { FormControlMixin } from '@umbraco-ui/uui-base/lib/mixins';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
function getNumberOrUndefined(value: string) {
const num = parseInt(value, 10);
return isNaN(num) ? undefined : num;
const num = parseInt(value, 10);
return isNaN(num) ? undefined : num;
}
@customElement('umb-input-number-range')
export class UmbInputNumberRangeElement extends FormControlMixin(UmbLitElement) {
static styles = [
UUITextStyles,
css`
static styles = [UUITextStyles, css``];
`,
];
@property({ type: String, attribute: 'min-label' })
minLabel = 'Low value';
@property({type: String, attribute:'min-label'})
minLabel = "Low value"
@property({type: String, attribute:'max-label'})
maxLabel = "High value"
@property({ type: String, attribute: 'max-label' })
maxLabel = 'High value';
@state()
private _minValue?: number;
@@ -30,8 +25,8 @@ export class UmbInputNumberRangeElement extends FormControlMixin(UmbLitElement)
public get minValue() {
return this._minValue;
}
public set minValue(keys: number | undefined) {
this._minValue = keys;
public set minValue(value: number | undefined) {
this._minValue = value;
this.updateValue();
}
@@ -41,22 +36,22 @@ export class UmbInputNumberRangeElement extends FormControlMixin(UmbLitElement)
public get maxValue() {
return this._maxValue;
}
public set maxValue(keys: number | undefined) {
this._maxValue = keys;
public set maxValue(value: number | undefined) {
this._maxValue = value;
this.updateValue();
}
private updateValue() {
const newValue = (this._minValue || this._maxValue) ? (this._minValue || '')+','+(this._maxValue || '') : '';
if(super.value !== newValue) {
const newValue = this._minValue || this._maxValue ? (this._minValue || '') + ',' + (this._maxValue || '') : '';
if (super.value !== newValue) {
super.value = newValue;
}
}
@property()
public set value(keysString: string) {
if(keysString !== this._value) {
const splittedValue = keysString.split(/[ ,]+/);
public set value(valueString: string) {
if (valueString !== this._value) {
const splittedValue = valueString.split(/[ ,]+/);
this.minValue = getNumberOrUndefined(splittedValue[0]);
this.maxValue = getNumberOrUndefined(splittedValue[1]);
}
@@ -66,26 +61,29 @@ export class UmbInputNumberRangeElement extends FormControlMixin(UmbLitElement)
super();
}
protected getFormElement() {
return this;
}
protected getFormElement() {
return this;
}
private _onMinInput(e:InputEvent) {
private _onMinInput(e: InputEvent) {
this.minValue = Number((e.target as HTMLInputElement).value);
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
}
private _onMaxInput(e:InputEvent) {
private _onMaxInput(e: InputEvent) {
this.maxValue = Number((e.target as HTMLInputElement).value);
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
}
render() {
return html`<uui-input type="number" .value=${this._minValue} @input=${this._onMinInput} label=${this.minLabel}></uui-input> <uui-input type="number" .value=${this._maxValue} @input=${this._onMaxInput} label=${this.maxLabel}></uui-input>`;
return html`<uui-input
type="number"
.value=${this._minValue}
@input=${this._onMinInput}
label=${this.minLabel}></uui-input>
<uui-input type="number" .value=${this._maxValue} @input=${this._onMaxInput} label=${this.maxLabel}></uui-input>`;
}
}
export default UmbInputNumberRangeElement;

View File

@@ -3,7 +3,6 @@ import { UmbTreeRepository } from '@umbraco-cms/backoffice/repository';
import type { ManifestTree } from '@umbraco-cms/backoffice/extensions-registry';
import { DeepState, UmbObserverController } from '@umbraco-cms/backoffice/observable-api';
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
import { UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api';
import { createExtensionClass, umbExtensionsRegistry } from '@umbraco-cms/backoffice/extensions-api';
export interface UmbTreeContext {
@@ -12,7 +11,7 @@ export interface UmbTreeContext {
readonly selection: Observable<Array<string>>;
setSelectable(value: boolean): void;
setSelection(value: Array<string>): void;
select(key: string): void;
select(id: string): void;
}
export class UmbTreeContextBase implements UmbTreeContext {
@@ -75,17 +74,17 @@ export class UmbTreeContextBase implements UmbTreeContext {
this.#selection.next(value);
}
public select(key: string) {
public select(id: string) {
const oldSelection = this.#selection.getValue();
if (oldSelection.indexOf(key) !== -1) return;
if (oldSelection.indexOf(id) !== -1) return;
const selection = [...oldSelection, key];
const selection = [...oldSelection, id];
this.#selection.next(selection);
}
public deselect(key: string) {
public deselect(id: string) {
const selection = this.#selection.getValue();
this.#selection.next(selection.filter((x) => x !== key));
this.#selection.next(selection.filter((x) => x !== id));
}
public async requestRootItems() {

View File

@@ -7,5 +7,5 @@ import type {
export interface TemplateTreeDataSource {
getRootItems(): Promise<DataSourceResponse<PagedEntityTreeItemResponseModel>>;
getChildrenOf(parentId: string): Promise<DataSourceResponse<PagedEntityTreeItemResponseModel>>;
getItems(key: Array<string>): Promise<DataSourceResponse<EntityTreeItemResponseModel[]>>;
getItems(ids: Array<string>): Promise<DataSourceResponse<EntityTreeItemResponseModel[]>>;
}

View File

@@ -66,7 +66,7 @@ export class UmbDictionaryDetailServerDataSource implements DictionaryDetailData
*/
async update(dictionary: DictionaryDetails) {
if (!dictionary.id) {
const error: ProblemDetailsModel = { title: 'Dictionary key is missing' };
const error: ProblemDetailsModel = { title: 'Dictionary id is missing' };
return { error };
}

View File

@@ -10,11 +10,11 @@ import type { DataSourceResponse } from '@umbraco-cms/backoffice/repository';
export interface DictionaryDetailDataSource {
createScaffold(parentId: string): Promise<DataSourceResponse<DictionaryItemResponseModel>>;
list(skip?: number, take?: number): Promise<DataSourceResponse<PagedDictionaryOverviewResponseModel>>;
get(key: string): Promise<DataSourceResponse<DictionaryItemResponseModel>>;
get(id: string): Promise<DataSourceResponse<DictionaryItemResponseModel>>;
insert(data: DictionaryDetails): Promise<DataSourceResponse>;
update(dictionary: DictionaryItemResponseModel): Promise<DataSourceResponse>;
delete(key: string): Promise<DataSourceResponse>;
export(key: string, includeChildren: boolean): Promise<DataSourceResponse<Blob>>;
delete(id: string): Promise<DataSourceResponse>;
export(id: string, includeChildren: boolean): Promise<DataSourceResponse<Blob>>;
import(fileName: string, parentId?: string): Promise<DataSourceResponse<any>>;
upload(formData: ImportDictionaryRequestModel): Promise<DataSourceResponse<string>>;
// TODO - temp only

View File

@@ -31,14 +31,14 @@ export class DictionaryTreeServerDataSource implements UmbTreeDataSource {
}
/**
* Fetches the children of a given parent key from the server
* Fetches the children of a given parent id from the server
* @param {(string | null)} parentId
* @return {*}
* @memberof DictionaryTreeServerDataSource
*/
async getChildrenOf(parentId: string | null) {
if (!parentId) {
const error: ProblemDetailsModel = { title: 'Parent key is missing' };
const error: ProblemDetailsModel = { title: 'Parent id is missing' };
return { error };
}

View File

@@ -85,13 +85,13 @@ export class UmbWorkspaceViewUsersGridElement extends UmbLitElement {
this.observe(this._usersContext.selection, (selection) => (this._selection = selection));
}
private _isSelected(key: string) {
return this._selection.includes(key);
private _isSelected(id: string) {
return this._selection.includes(id);
}
//TODO How should we handle url stuff?
private _handleOpenCard(key: string) {
history.pushState(null, '', 'section/users/view/users/user/' + key); //TODO Change to a tag with href and make dynamic
private _handleOpenCard(id: string) {
history.pushState(null, '', 'section/users/view/users/user/' + id); //TODO Change to a tag with href and make dynamic
}
private _selectRowHandler(user: UserEntity) {
@@ -104,8 +104,8 @@ export class UmbWorkspaceViewUsersGridElement extends UmbLitElement {
private _getUserGroupNames(ids: Array<string>) {
return ids
.map((key: string) => {
return this._userGroups.find((x) => x.id === key)?.name;
.map((id: string) => {
return this._userGroups.find((x) => x.id === id)?.name;
})
.join(', ');
}

View File

@@ -49,8 +49,8 @@ export class UmbEntityData<T extends Entity> extends UmbData<T> {
trash(ids: Array<string>) {
const trashedItems: Array<T> = [];
ids.forEach((key) => {
const item = this.getById(key);
ids.forEach((id) => {
const item = this.getById(id);
if (!item) return;
// TODO: how do we handle trashed items?

View File

@@ -12,8 +12,8 @@ class UmbLanguagesData extends UmbData<LanguageResponseModel> {
return this.data.slice(skip, take);
}
getByKey(key: string) {
return this.data.find((item) => item.isoCode === key);
getByKey(isoCode: string) {
return this.data.find((item) => item.isoCode === isoCode);
}
insert(language: LanguageResponseModel) {

View File

@@ -17,7 +17,7 @@ export const handlers = [
}),
rest.get('/umbraco/management/api/v1/tree/media-type/item', (req, res, ctx) => {
const ids = req.url.searchParams.getAll('key');
const ids = req.url.searchParams.getAll('id');
if (!ids) return;
const items = umbMediaTypeData.getTreeItem(ids);

View File

@@ -9,7 +9,7 @@ export const handlers = [
}),
rest.get('/umbraco/management/api/v1/tree/member-group/item', (req, res, ctx) => {
const ids = req.url.searchParams.getAll('key');
const ids = req.url.searchParams.getAll('id');
if (!ids) return;
const items = umbMemberGroupData.getTreeItem(ids);

View File

@@ -9,7 +9,7 @@ export const handlers = [
}),
rest.get('/umbraco/management/api/v1/tree/member-type/item', (req, res, ctx) => {
const ids = req.url.searchParams.getAll('key');
const ids = req.url.searchParams.getAll('id');
if (!ids) return;
const items = umbMemberTypeData.getTreeItem(ids);

View File

@@ -9,7 +9,7 @@ export const handlers = [
}),
rest.get('/umbraco/management/api/v1/tree/member/item', (req, res, ctx) => {
const ids = req.url.searchParams.getAll('key');
const ids = req.url.searchParams.getAll('id');
if (!ids) return;
const items = umbMemberData.getTreeItem(ids);

View File

@@ -16,7 +16,7 @@ export const handlers = [
}),
rest.get('/umbraco/management/api/v1/tree/media/item', (req, res, ctx) => {
const ids = req.url.searchParams.getAll('key');
const ids = req.url.searchParams.getAll('id');
if (!ids) return;
const items = umbMediaData.getTreeItem(ids);