Add New buttons to browser modals

This commit is contained in:
Sipke Schoorstra 2022-07-21 17:28:58 +02:00
parent 7772213204
commit 765e572d06
4 changed files with 15 additions and 7 deletions

View file

@ -906,6 +906,7 @@ declare namespace LocalJSX {
"variables"?: Array<Variable>;
}
interface ElsaWorkflowDefinitionBrowser {
"onNewWorkflowDefinitionSelected"?: (event: CustomEvent<any>) => void;
"onWorkflowDefinitionSelected"?: (event: CustomEvent<WorkflowDefinitionSummary>) => void;
}
interface ElsaWorkflowDefinitionEditor {

View file

@ -53,7 +53,7 @@ export class ActivityDefinitionsPlugin implements Plugin {
studioComponentStore.modalComponents = [
...studioComponentStore.modalComponents,
() => <elsa-activity-definition-browser ref={el => this.activityDefinitionBrowserElement = el} onActivityDefinitionSelected={this.onActivityDefinitionSelected}/>];
() => <elsa-activity-definition-browser ref={el => this.activityDefinitionBrowserElement = el} onActivityDefinitionSelected={this.onActivityDefinitionSelected} onNewActivityDefinitionSelected={this.onNewActivityDefinitionClick}/>];
}
async initialize(): Promise<void> {

View file

@ -27,7 +27,8 @@ export class WorkflowDefinitionBrowser {
this.api = Container.get(WorkflowDefinitionsApi);
}
@Event() public workflowDefinitionSelected: EventEmitter<WorkflowDefinitionSummary>;
@Event() workflowDefinitionSelected: EventEmitter<WorkflowDefinitionSummary>;
@Event() public newWorkflowDefinitionSelected: EventEmitter;
@State() private workflowDefinitions: PagedList<WorkflowDefinitionSummary> = { items: [], totalCount: 0 };
@State() private publishedWorkflowDefinitions: PagedList<WorkflowDefinitionSummary> = { items: [], totalCount: 0 };
@State() private selectedWorkflowDefinitionIds: Array<string> = [];
@ -38,16 +39,21 @@ export class WorkflowDefinitionBrowser {
@State() private selectAllChecked: boolean;
@Method()
public async show() {
async show() {
await this.modalDialog.show();
await this.loadWorkflowDefinitions();
}
@Method()
public async hide() {
async hide() {
await this.modalDialog.hide();
}
private onNewDefinitionClick = async () => {
this.newWorkflowDefinitionSelected.emit();
await this.hide();
};
private async onPublishClick(e: MouseEvent, workflowDefinition: WorkflowDefinitionSummary) {
await this.api.publish(workflowDefinition);
await this.loadWorkflowDefinitions();
@ -116,7 +122,7 @@ export class WorkflowDefinitionBrowser {
this.workflowDefinitions = latestWorkflowDefinitions;
}
onPaginated = async (e: CustomEvent<PagerData>) => {
private onPaginated = async (e: CustomEvent<PagerData>) => {
this.currentPage = e.detail.page;
await this.loadWorkflowDefinitions();
};
@ -177,7 +183,8 @@ export class WorkflowDefinitionBrowser {
const publishedWorkflowDefinitions = this.publishedWorkflowDefinitions.items;
const totalCount = workflowDefinitions.totalCount;
const closeAction = DefaultActions.Close();
const actions = [closeAction];
const newAction = DefaultActions.New(this.onNewDefinitionClick);
const actions = [closeAction, newAction];
const filterProps: FilterProps = {
pageSizeFilter: {

View file

@ -50,7 +50,7 @@ export class WorkflowDefinitionsPlugin implements Plugin {
studioComponentStore.modalComponents = [
...studioComponentStore.modalComponents,
() => <elsa-workflow-definition-browser ref={el => this.workflowDefinitionBrowserElement = el} onWorkflowDefinitionSelected={this.onWorkflowDefinitionSelected}/>];
() => <elsa-workflow-definition-browser ref={el => this.workflowDefinitionBrowserElement = el} onWorkflowDefinitionSelected={this.onWorkflowDefinitionSelected} onNewWorkflowDefinitionSelected={this.onNewWorkflowDefinitionClick}/>];
}
async initialize(): Promise<void> {