Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v14.07.03 LTS #122

Merged
merged 11 commits into from
Jul 5, 2022
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "2sxc-ui",
"version": "14.07.00",
"version": "14.07.03",
"description": "2sxc UI - the JS UI of 2sxc",
"scripts": {
"release-all": "npm run js2sxc && npm run inpage && npm run snippets && npm run quickdialog && npm run turn-on",
Expand Down
21 changes: 13 additions & 8 deletions projects/$2sxc/src/_/Window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ import { SxcGlobal } from '../sxc-global';
* @public
*/
declare global {
interface Window {
/**
* The global $2sxc object / function to generate Sxc instances
*/
$2sxc: SxcGlobal;
interface Window {
/**
* The global $2sxc object / function to generate Sxc instances
*/
$2sxc: SxcGlobal;

/** @internal */
$: any & DnnJQueryExtensions;
}
/** @internal */
$: any & DnnJQueryExtensions;
}

/**
* The global $2sxc object / function to generate Sxc instances
*/
const $2sxc: SxcGlobal;
}

/** @internal */
Expand Down
4 changes: 3 additions & 1 deletion projects/$2sxc/src/cms/command-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* Names of commands known to 2sxc CMS - for use in toolbars and calling commands directly from code
* @public
*/
export enum CommandNames {
// IMPORTANT: this must be a `const enum`, otherwise it won't work in d.ts files
export const enum CommandNames {
/**
* `add` adds another demo-item to a **list of items**.
* It does not open the edit-dialog.
Expand Down Expand Up @@ -114,6 +115,7 @@ export enum CommandNames {
* `code` will execute custom javascript.
* <br> 🔘 This is mainly for toolbars, to add buttons with custom code.
* <br> 📩 [Parameters](xref:Api.Js.SxcJs.CommandCodeParams)
* <br> _this used to be called `custom` and had a different setup_
*/
code = 'code',

Expand Down
118 changes: 86 additions & 32 deletions projects/$2sxc/src/cms/command-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,83 +2,137 @@
import { TypeValue } from '../../../inpage/src/plumbing';

/**
* Command parameters are handed over to a command for execution
* Command parameters are handed over to a command for execution.
* It contains all possible combinations of parameters that can be used in a command.
*
* We will try to improve how this is documented, but ATM it just has all parameters,
* even though you may need none, or just a few.
*
* _Note: For your specific commands, you can also pass other parameters._
*
* **Important for the docs**
*
* Most properties are actually not visible (you will get them in the types though).
* So actually you will usually create one of these:
* * [](xref:Api.Js.SxcJs.CommandParamsEntityById)
* * [](xref:Api.Js.SxcJs.CommandParamsEntityInContentBlock)
* * [](xref:Api.Js.SxcJs.CommandParamsEntityInList)
* * [](xref:Api.Js.SxcJs.CommandAddParams)
* * [](xref:Api.Js.SxcJs.CommandAddExistingParams)
* * [](xref:Api.Js.SxcJs.CommandDataParams)
* * [](xref:Api.Js.SxcJs.CommandCopyParams)
* * [](xref:Api.Js.SxcJs.CommandCodeParams)
* * [](xref:Api.Js.SxcJs.CommandDeleteParams)
* * [](xref:Api.Js.SxcJs.CommandMetadataParams)
* * [](xref:Api.Js.SxcJs.CommandNewParams)
*
* Because of this, most of the properties below are NOT documented, as their purpose can change depending on the command used.
* @public
*/
export interface CommandParams {
export interface CommandParams extends Record<string, unknown>
// We cannot extend from the real parameters, because this won't make it into the documentation
// extends Partial<CommandParamsEntityById>, Partial<CommandParamsEntity>
{
/**
* The action is used in scenarios where the command name must be included
* @internal - wait with publishing this, it shouldn't actually be here. we may need to create another type which includes it
*/
action?: CommandNames;

/** @internal */
items?: Array<ItemIdentifierSimple | ItemIdentifierGroup>;
/** @internal */

/**
* Special change of dialogs, for example to change the edit-dialog into a new-dialog.
* @internal - not sure how this matches / replaces dialog, probably internal only
*/
mode?: string;

// both contentType and contentTypeName were used historically, so both variations may exist in Razor templaets
/** @internal */
/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
contentType?: string;
/** @internal */
/** @internal old */
contentTypeName?: string;

/** @internal */
pipelineId?: number;
/** @internal */
/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
filters?: string;
/** @internal */
dialog?: string;

/**
* @internal
* @deprecated but probably still in use
* @deprecated but still in use
*/
sortOrder?: number;

/**
* Position in a list (content-block or field of another entity)
* index was added in v14.04 to replace the `sortOrder` which had a confusing name.
* @internal
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
index?: number;

/** @internal */
/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
entityId?: number;

/**
* The guid - for people creating custom toolbars before 10.27 or automatically added since 10.27
* @internal
/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
entityGuid?: string;

/**
* The manually added title from before 10.27 - automatically enabled the delete-button
* @internal
/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
entityTitle?: string;

/** @internal */
/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
title?: string;

/** @internal */
useModuleList?: boolean;
/** @internal */
/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
useModuleList?: true;

/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
metadata?: CommandParamsMetadata;

/** @internal */
isPublished?: boolean;
/** @internal */
prefill?: Record<string, TypeValue>;

/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
prefill?: Record<string, boolean | string | number | Date>;

/**
* Custom Code in the previous V9 standard
* @internal
*/
customCode?: string;

/**
* Custom Code function name only in the new V10.27 standard
* @internal
/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
call?: string;

Expand All @@ -89,14 +143,14 @@ export interface CommandParams {
*/
apps?: string;

/**
* Experimental in 10.27
* @internal
/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
parent?: string;
/**
* Experimental in 10.27
* @internal
/**
* The purpose of this varies by [Command](xref:Api.Js.SxcJs.CommandNames).
* @public
*/
fields?: string;

Expand Down
3 changes: 1 addition & 2 deletions projects/$2sxc/src/cms/run-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export interface RunParams {

/**
* The command params, like contentType, entityId etc.
* Optional for many actions, but can themselves also contain the property `action`, in which case action can be ommited.
* @internal
* Optional for many actions.
*/
params?: CommandParams;

Expand Down
2 changes: 0 additions & 2 deletions projects/$2sxc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ export * from './cms';
export * from './sxc';

export * from './sxc-global';

(window as any).beta = new ToolUrlObjects();
4 changes: 2 additions & 2 deletions projects/inpage/src/commands/command/command-content-type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Command, CommandContentTypeParams, CommandNames, Commands } from '..';
import { Command, CommandContentTypeParams, CommandNames, CommandParams, Commands } from '..';
import { ContextComplete } from '../../context';

/**
Expand All @@ -23,7 +23,7 @@ Commands.addCommand(Command.clone(cmd, CommandNames.fields_old_contenttype));
/**
* @internal
*/
export function createContentTypeParams(context: ContextComplete) {
export function createContentTypeParams(context: ContextComplete): { contentType: string } {
const result: CommandContentTypeParams = {
contentType: context.button.command.params.contentType
|| context.contentBlock.contentTypeId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
export interface CommandParamsEntityInContentBlock {
/**
* Determins the position of the item in the list.
* index was added in v14.04 to replace the `sortOrder` which had a confusing name.
*/
index: number;

Expand Down
17 changes: 9 additions & 8 deletions projects/inpage/src/commands/engine/cms-engine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RunParams } from '../../../../$2sxc/src/cms';
import { CommandParams } from '../../../../$2sxc/src/cms';
import { RunParamsHelpers } from '../../cms/run-params-helpers';
import { ContentBlockEditor } from '../../contentBlock/content-block-editor';
import { renderer } from '../../contentBlock/render';
Expand All @@ -11,9 +12,8 @@ import { ButtonCommand } from '../../toolbar/config';
import { InPageButtonJson } from '../../toolbar/config-loaders/config-formats/in-page-button';
import { WorkflowHelper, WorkflowPhases, WorkflowStepCodeArguments } from '../../workflow';
import { ToolbarWorkflowManager } from '../../workflow/toolbar-workflow-manager';
import { CommandLinkGenerator } from '../command-link-generator';
import { CommandParams } from '../../../../$2sxc/src/cms';
import { WorkflowStep } from '../../workflow/workflow-step';
import { CommandLinkGenerator } from '../command-link-generator';

type CommandPromise<T> = Promise<T|void>;

Expand Down Expand Up @@ -75,12 +75,14 @@ export class CmsEngine extends HasLog {

const origEvent = event;
const name = cmdParams.action;
const contentType = cmdParams.contentType;
cl.add(`run command '${name}' for type ${contentType}`);
// 2dm 2022-07-05 #badContentTypeExtractAndRefill - we seem to extract it, just to put it back on the ButtonCommand
// const contentType = cmdParams.contentType;
// cl.add(`run command '${name}' for type ${contentType}`);
cl.add(`run command '${name}'`);

// Toolbar API v2
const command = new ButtonCommand(name, contentType, cmdParams);
const newButtonConfig = new Button(command, command.name);
const btnCommand = new ButtonCommand(name, /* contentType, */ cmdParams);
const newButtonConfig = new Button(btnCommand, btnCommand.name);

// merge conf & settings, but settings has higher priority
const button: Button = {
Expand Down Expand Up @@ -124,8 +126,7 @@ export class CmsEngine extends HasLog {
} else {
// if more than just a UI-action, then it needs to be sure the content-group is created first
cl.add('command might change data, wrap in pre-flight to ensure content-block');
finalPromise = wrapperPromise.then(
(wfArgs) => WorkflowHelper.isCancelled(wfArgs)
finalPromise = wrapperPromise.then((wfArgs) => WorkflowHelper.isCancelled(wfArgs)
? Promise.resolve<T>(null)
: ContentBlockEditor.singleton()
.prepareToAddContent(context, cmdParams.useModuleList)
Expand Down
2 changes: 1 addition & 1 deletion projects/inpage/src/sxc/sxc-cms-real.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class SxcCmsReal extends SxcCms {
*/
run<T>(runParams: RunParams): Promise<void | T> {
RunParamsHelpers.ensureRunParamsInstanceOrError(runParams);
return new SxcGlobalCms().run({ ...runParams, context: this.sxc });
return new SxcGlobalCms().runInternal({ ...runParams, context: this.sxc });
}

// runTemplateDevelop() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ToolbarConfigLoader } from '.';
import { InPageCommandJson, InPageCommandJsonWithTooMuchInfo } from '.';
import { InPageCommandJsonWithTooMuchInfo } from '.';
import { CommandParams } from '../../../../$2sxc/src/cms';
import { HasLog } from '../../core';

/**
Expand All @@ -16,23 +17,24 @@ export class CommandConfigLoader extends HasLog {
* because the target item could be specified directly, or in a complex internal object called entity
* @param actDef
*/
updateToV9(actDef: InPageCommandJsonWithTooMuchInfo): InPageCommandJson {
updateToV9(actDef: InPageCommandJsonWithTooMuchInfo): CommandParams {

// doesn't have the pre-V9 properties, so we're fine
if (!actDef.entity || !actDef.entity._2sxcEditInformation)
return actDef as InPageCommandJson;
return actDef as CommandParams;

const editInfo = actDef.entity._2sxcEditInformation;

// move up sortOrder property and set useModuleList
actDef.useModuleList = (editInfo.sortOrder !== undefined); // has sort-order, so use list
if (editInfo.sortOrder !== undefined)
actDef.useModuleList = true; // has sort-order, so use list
if (editInfo.sortOrder !== undefined) actDef.sortOrder = editInfo.sortOrder;

// move up entityId and clean-up the old 'entity' property
if (actDef.entity.EntityId !== undefined) actDef.entityId = actDef.entity.EntityId;
delete actDef.entity;

return actDef;
return actDef as unknown as CommandParams;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class InPageCommandJson {
contentType?: string;

/** determines that we should use a module list */
useModuleList?: boolean;
useModuleList?: true;

/** index in the list */
sortOrder?: number;
Expand Down
Loading