Skip to main content

Buttons

A sub namespace of UI, exclusive for buttons operations

//accessing to ui.buttons methods
SW.UI.Buttons.{methodName}

addCreateToSubHeader

Description

This method can be used to generate a create button in the sub-header.

Method(s)

function addCreateToSubHeader(documentName: string, component: dxForm,
params: {
onClick?: (dashboardDocumentSaveObject: DashboardDocumentSaveObject) => boolean;
components?: {
description?: dxHtmlEditor;
files?: FileSystemWidgetComponent;
};
mappers?: {
postModel?: (
postModel: PostModel,
dashboardDocumentSaveObject: DashboardDocumentSaveObject,
params: { isDraftModel: boolean }
) => PostModel;
briefPostModel?: (
briefPostModel: BriefPostModel,
dashboardDocumentSaveObject: DashboardDocumentSaveObject
) => BriefPostModel;
};
postChangesOnFeed?: boolean;
allowDraft?: boolean;
icons?: {
save?: {
class?: string;
tooltip?: string;
};
draft?: {
class?: string;
tooltip?: string;
};
};
} = {
allowDraft: true,
postChangesOnFeed: false
}
): void
ParameterTypeRequiredDefaultsDescription
documentNamestringtrueDocument name
componentdxFormtrueForm where it will be added the button
descriptionComponentanytruenull
onClickFunctionfalseOn button click function
callBackanytrueCallback function
descriptiondxHtmlEditorfalseDescription box
filesFileSystemWidgetComponentfalseFile upload component
postModelPostModelfalsePost model for document creation
dashboardDocumentSaveObjectDashboardDocumentSaveObjectfalseObject to save document
isDraftModelbooleanfalseIf document is draft
briefPostModelBriefPostModelfalseBrief post model
dashboardDocumentSaveObjectDashboardDocumentSaveObjectfalseObject to save document
postChangesOnFeedbooleanfalseFlag to allow changes on feed
allowDraftbooleanfalseIf document can be draft
classstringfalseSave button icon
tooltipstringfalseSave button tooltip
classstringfalseDraft button icon
tooltipstringfalseDraft button tooltip

Basic Usage

SW.UI.Buttons.addCreateToSubHeader("project", e.component, 
{
onClick: (postModel, dashboardDocumentSaveObject) => {
postModel["Custom"] = {
JobTypeId: postModel.Actions.Document.Project.ProjectNatureId
};
return postModel;
},
components: {
description: SW.getComponent("description")
}
}
);

Response

img


addSaveToSubHeader

Description

This method can be used to generate a save button in the sub-header.

Method(s)

function addSaveToSubHeader(documentName: string, component: dxForm,
params: {
patchEndpoint?: string;
onClick?: (currentDocument: Document, formComponent: dxForm, otherFields: any) => void;
postChangesOnFeed?: boolean;
icons?: {
save?: {
class?: string;
tooltip?: string;
};
};
} = {
postChangesOnFeed: false
}
): void
ParameterTypeRequiredDefaultsDescription
documentNamestringtrueDocument name
componentdxFormtrueForm where it will be added the button
patchEndpointstringfalseEndpoint for patch request
onClickFunctionfalseOn button click function
postChangesOnFeedbooleanfalseFlag to allow changes on feed
classstringfalseButton icon
tooltipstringfalseButton tooltip

Basic Usage

SW.UI.Buttons.addSaveButtonToSubHeader("commercialclient", e.component, {postChangesOnFeed: true });  

Response

img


addToSubHeader

Description

This method can be used to add buttons to the sub-header.

Method(s)

1   function addToSubHeader(component: DOMComponent, buttons: SubHeaderButton[]): void
ParameterTypeRequiredDefaultsDescription
componentDOMComponenttrueParent component where the buttons will be added
buttonsSubHeaderButton[]trueAn array of buttons

Basic Usage

SW.UI.Buttons.addToSubHeader(e.component, buttons);
important

Buttons have the following structure

img

Response

img


setAllEnabled

Description

This method can be used to enable or disable buttons.

Method(s)

1   function setAllEnabled(value: boolean): void
ParameterTypeRequiredDefaultsDescription
valuebooleantrueTrue to enbale and false to disable

Basic Usage

SW.UI.Buttons.setAllEnabled(true)