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

Add close form button on deep relations form #141

Open
wants to merge 34 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3cc12d6
:sparkles: Start to develop edit multi relation feature from multi pa…
volterra79 Nov 22, 2024
f60d8c5
:sparkles: Start to develop edit multi relation feature from multi pa…
volterra79 Nov 25, 2024
14406e1
:sparkles: Add reset method step
volterra79 Nov 25, 2024
d695f3f
Clean code - spaces
volterra79 Nov 25, 2024
1286a0c
:bug: Add user message to copy paste from other layer
volterra79 Nov 25, 2024
d2f36cb
Clean code - spaces
volterra79 Nov 26, 2024
7e7da7e
Use steps message to address user to follow right flow
volterra79 Nov 26, 2024
51c3e1a
:recycle: Use class instead base or inherit
volterra79 Nov 26, 2024
04543e1
:sparkles: Add close form on deep relations
volterra79 Dec 2, 2024
84a5922
Align close button behavior with dev
volterra79 Dec 3, 2024
fec6b77
Remove setModal false
volterra79 Dec 3, 2024
278e739
Merge branch 'issue_137' into issue_137_close
volterra79 Dec 3, 2024
611b4ce
Create internal step method stopRun
volterra79 Dec 3, 2024
7eb93aa
Merge branch 'dev' into issue_137
volterra79 Dec 3, 2024
daf91d9
:sparkles: Show modal select window to choose whild features of selec…
volterra79 Dec 5, 2024
66822c8
:bug: get relation only editable, not also visible
volterra79 Dec 6, 2024
4dcfa5a
:globe_with_meridians:translation
volterra79 Dec 6, 2024
7b9a44a
:lipstick: run Once
volterra79 Dec 6, 2024
f015f97
Remove copy feature form external layer tool. Unused
volterra79 Dec 10, 2024
77381c1
:recycle: Handle start toolbox session uniform
volterra79 Dec 10, 2024
96bbe9b
Comment getEditingMediaFields to copy also attach (media, pdf,etcc.) …
volterra79 Dec 11, 2024
b733b10
:bug: In case of no relations, show user message and stop
volterra79 Dec 11, 2024
29fa953
:sparkles: Referred to https://github.com/g3w-suite/g3w-admin/pull/991
volterra79 Dec 12, 2024
2997529
:bug: Unlock relations layers in case of editing relation by parent l…
volterra79 Dec 12, 2024
127b1c6
Remove return Promise.reject because cause a vue error
volterra79 Dec 13, 2024
2290dee
Remove unusefull new
volterra79 Dec 13, 2024
7de5da9
Merge branch 'issue_137' into issue_137_close
volterra79 Dec 16, 2024
0b5f4ed
Merge branch 'dev' into issue_137_close
volterra79 Dec 16, 2024
e4e482a
:lipstick: display save and close
volterra79 Dec 16, 2024
370fdbf
:bug: Rollback _rejectRun attribute
volterra79 Dec 20, 2024
c6c2b6f
:bug: Fix unselect feature after close depp relation form
volterra79 Dec 30, 2024
66f2365
:recycle: Move dissolve method to g3w-client core
volterra79 Dec 30, 2024
05386bb
:art: css panel-body
volterra79 Jan 2, 2025
a84e72a
:bug: Fix close deep form on relation
volterra79 Jan 3, 2025
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
6 changes: 4 additions & 2 deletions components/Toolbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@
padding: 13px;
color: currentColor !important;
font-size: 1.1em;
margin: 0px;
margin: 0;
}
.panel-title {
font-weight: bold;
Expand Down Expand Up @@ -655,7 +655,6 @@
margin-bottom: 5px;
font-size: 1.1em;
color: #000;
margin-top: 5px;
}
.snap-tool {
display: flex;
Expand All @@ -671,6 +670,9 @@
.tools-of-tool-snap label span {
color: #222d32 !important;
}
.panel-body {
padding: 15px;
}
.panel-body.disabled {
opacity: .7;
}
Expand Down
16 changes: 10 additions & 6 deletions g3wsdk/workflow/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class Step extends G3WObject {

this._options = options;

//store promise of current running step when call run
this._run = (options.run || this.run || (async () => true)).bind(this);
//store promise of current running step when call stop
this._stop = (options.stop || this.stop || (async () => true)).bind(this);

/**
Expand Down Expand Up @@ -102,7 +104,7 @@ export class Step extends G3WObject {
* @since [email protected]
*/
if (options.onStop) {
this.on('run', options.onStop);
this.on('stop', options.onStop);
}

/**
Expand Down Expand Up @@ -389,7 +391,7 @@ export class Step extends G3WObject {
*/
registerEscKeyEvent(callback) {
if (callback) {
this.on('run', () => this.bindEscKeyUp(callback));
this.on('run', () => this.bindEscKeyUp(callback));
this.on('stop', () => this.unbindEscKeyUp());
}
}
Expand All @@ -410,10 +412,12 @@ export class Step extends G3WObject {
*/
__run(inputs, context) {
return $promisify(async() => {
//set step inputs
this.setInputs(inputs);
//set step context
this.setContext(context);

const step = this;
const step = this;
const toolsOfTools = {

snap: {
Expand Down Expand Up @@ -471,7 +475,7 @@ export class Step extends G3WObject {
try {
this.state.running = true; // change state to running
return await promisify(this._run(inputs, context));
} catch (e) {
} catch(e) {
console.warn(e);
this.state.error = e;
return Promise.reject(e);
Expand All @@ -489,8 +493,8 @@ export class Step extends G3WObject {
*
* @fires stop
*/
__stop() {
this._stop(this._inputs, this._context); // stop task
async __stop() {
await this._stop(this._inputs, this._context); // stop task
this.state.running = false; // remove running state
if (this._workflow) {
this._workflow._toolsoftool.forEach(t => t.options.stop());
Expand Down
66 changes: 37 additions & 29 deletions g3wsdk/workflow/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,6 @@ export class Workflow extends G3WObject {
}
}

/**
* @FIXME add description
*/
removeChild() {
if (this._child) {
Workflow.Stack.removeAt(this._child.getStackIndex());
}
this._child = null;
}

/**
* @param input.key
* @param input.value
Expand Down Expand Up @@ -298,7 +288,7 @@ export class Workflow extends G3WObject {
/**
* @FIXME add description
*/
reject () {
reject() {
if (this._promise) {
this._promise.reject();
}
Expand All @@ -314,19 +304,28 @@ export class Workflow extends G3WObject {
}
}

/**
* Method to run steps of workflow
* @param step
* @param inputs
* @return {Promise<unknown>}
*/
async runStep(step, inputs) {
try {
//set step message
this.setMessages({ help: step.state.help });
//run step
const outputs = await promisify(step.__run(inputs, this.getContext()));
// onDone → check if all step is resolved
this._stepIndex++;
//check if is the last of workflow steps
if (this._stepIndex === this.getSteps().length) {
this._stepIndex = 0;
return outputs;
} else {
return this.runStep(this.getSteps()[this._stepIndex], outputs);
}
} catch (e) {
} catch(e) { //In case of reject
this._stepIndex = 0;
return Promise.reject(e);
}
Expand Down Expand Up @@ -358,13 +357,15 @@ export class Workflow extends G3WObject {
) {
Workflow.Stack.getCurrent().addChild(this)
}


//get stack index
this._stackIndex = Workflow.Stack.push(this);
//get steps
this._steps = options.steps || this._steps;

//for each step assign current workflow to _workflow
(this._steps || []).forEach(s => s._workflow = this);

const showUserMessage = Object.keys(this._userMessageSteps).length;
const showUserMessage = Object.keys(this._userMessageSteps).length > 0;

if (showUserMessage) {
GUI.showUserMessage({
Expand All @@ -383,26 +384,28 @@ export class Workflow extends G3WObject {
}
});
}
//emit start
//emit start Workflow
this.emit('start');

try {
console.assert(0 === this._stepIndex, `reset workflow before restarting: ${this._stepIndex}`)
//start flow of workflow
const outputs = await this.runStep(this.getSteps()[this._stepIndex], this.getInputs());
//In case of show user message (tool steps)
if (showUserMessage) {
setTimeout(() => { this.clearUserMessagesSteps(); resolve(outputs); }, 500);
} else {
resolve(outputs);
}
} catch (e) {
} catch(e) {
console.warn(e);
if (showUserMessage) {
this.clearUserMessagesSteps();
}
reject(e);
}

//in case of worflow that need to run once time, stop workflow
if (this.runOnce) {
this.stop();
}
Expand All @@ -414,31 +417,32 @@ export class Workflow extends G3WObject {
*
* @fires stop
*/
stop() {
async stop() {
return $promisify(new Promise(async (resolve, reject) => {

this._promise = null;

try {
// stop child workflow
if (this._child) {
await promisify(this._child.stop());
await promisify(this._child.stop());
}
} catch(e) {
console.warn(e);
}

// ensure that child is always removed
this.removeChild();

Workflow.Stack.removeAt(this.getStackIndex());
//remove child
this._child = null;

// stop flow
try {
if (this.getSteps()[this._stepIndex].isRunning()) {
//get current step
const step = this.getSteps()[this._stepIndex];
//check if it is running
if (step.isRunning()) {
//clear messages steps
this.clearMessages();
//stop a current step
this.getSteps()[this._stepIndex].__stop();
//wait stop run
await step.__stop();
}
// reset counter and reject flow
if (this._stepIndex > 0) {
Expand All @@ -448,11 +452,15 @@ export class Workflow extends G3WObject {
} else {
resolve();
}
} catch (e) {
} catch(e) {
console.warn(e);
reject(e);
}

//remove workflow from stack
Workflow.Stack.removeAt(this.getStackIndex());

//emit stop Workflow
this.emit('stop');

}));
Expand Down Expand Up @@ -634,5 +642,5 @@ Workflow.Stack = {
removeAt(i) { workflows.splice(i, 1); },
insertAt(i, w) { workflows[i] = w; },
getAt(i) { return workflows[i]; },
clear() { while (workflows.length) { (workflows.pop()).stop(); } },
async clear() { workflows.splice(0); }
};
5 changes: 2 additions & 3 deletions toolboxes/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { promisify, $promisify } from '../utils/promisify
import { unlinkRelation } from '../utils/unlinkRelation';
import { splitFeatures } from '../utils/splitFeatures';
import { isSameBaseGeometryType } from '../utils/isSameBaseGeometryType';
import { dissolve } from '../utils/dissolve';
import { PickFeaturesInteraction } from '../interactions/pickfeaturesinteraction';

import {
Expand Down Expand Up @@ -59,7 +58,7 @@ const {
const { ProjectsRegistry } = g3wsdk.core.project;
const { DataRouterService } = g3wsdk.core.data;
const { CatalogLayersStoresRegistry } = g3wsdk.core.catalog;
const { Geometry } = g3wsdk.core.geoutils;
const { Geometry, dissolve } = g3wsdk.core.geoutils;
const { removeZValueToOLFeatureGeometry } = g3wsdk.core.geoutils.Geometry;
const { tPlugin } = g3wsdk.core.i18n;
const { Layer } = g3wsdk.core.layer;
Expand Down Expand Up @@ -544,7 +543,7 @@ export class ToolBox extends G3WObject {
context: {
session: Workflow.Stack.getCurrent().getSession(), // get parent workflow
excludeFields: fields.ownField, // array of fields to be excluded
isContentChild: false, //@since 3.9.0 force child to flase
isContentChild: false, //@since 3.9.0 force child to false
},
inputs: {
features: rLayer.readFeatures(),
Expand Down
81 changes: 0 additions & 81 deletions utils/dissolve.js

This file was deleted.

Loading