Skip to content

Commit

Permalink
Merge branch 'next' into epic/FOUR-18018
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjacornelius committed Oct 7, 2024
2 parents c7aa325 + 3115ef5 commit 97354cb
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 18 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@processmaker/screen-builder",
"version": "2.98.4",
"version": "2.99.3",
"scripts": {
"dev": "VITE_COVERAGE=true vite",
"build": "vite build",
Expand Down Expand Up @@ -56,7 +56,7 @@
"@fortawesome/fontawesome-free": "^5.6.1",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@panter/vue-i18next": "^0.15.2",
"@processmaker/vue-form-elements": "0.59.0",
"@processmaker/vue-form-elements": "0.60.0",
"@processmaker/vue-multiselect": "2.3.0",
"@storybook/addon-essentials": "^7.6.13",
"@storybook/addon-interactions": "^7.6.13",
Expand Down Expand Up @@ -115,7 +115,7 @@
},
"peerDependencies": {
"@panter/vue-i18next": "^0.15.0",
"@processmaker/vue-form-elements": "0.59.0",
"@processmaker/vue-form-elements": "0.60.0",
"i18next": "^15.0.8",
"vue": "^2.6.12",
"vuex": "^3.1.1"
Expand Down
12 changes: 11 additions & 1 deletion src/DataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,26 @@ export default {
const hasIncludeScreen = params.match(/include=.*,screen,/);
const hasIncludeNested = params.match(/include=.*,nested,/);

// Extract screen_version from params.
const screenVersionMatch = params.match(/screen_version=([^&]+)/);
const screenVersion = screenVersionMatch ? screenVersionMatch[1] : null;

// remove params ?...
promises.push(
this.get(endpoint + params.replace(/,screen,|,nested,/g, ","))
);
// Get the screen from a separated cached endpoint
if (hasIncludeScreen) {
const screenEndpoint = `${(endpoint + params).replace(
let screenEndpoint = `${(endpoint + params).replace(
/\?.+$/,
""
)}/screen?include=screen${hasIncludeNested ? ",nested" : ""}`;

// Append screen_version only if screenVersion is not empty.
if (screenVersion) {
screenEndpoint += `&screen_version=${screenVersion}`;
}

promises.push(this.get(screenEndpoint));
}
// Await for both promises to resolve
Expand Down
19 changes: 19 additions & 0 deletions src/components/renderer/file-upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@upload-start="start"
@file-removed="removed"
@file-success="fileUploaded"
@file-error="fileError"
@file-added="addFile"
:class="{'was-validated': required}"
>
Expand Down Expand Up @@ -570,6 +571,24 @@ export default {
e.target.click();
}
},
fileError(rootFile, file, messages, chunk)
{
let displayMessage = '';
try {
const messagesArray = JSON.parse(messages);
displayMessage = messagesArray.join(', ');
}
catch (e) {
displayMessage = messages;
}
if (displayMessage.length > 0) {
window.ProcessMaker.alert(`${this.$t('File Upload Error:')} ${displayMessage}`, 'danger');
}
window.onbeforeunload = function() {};
this.$emit('file-error', messages);
},
fileUploaded(rootFile, file, message) {
this.uploading = false;
let name = file.name;
Expand Down
48 changes: 41 additions & 7 deletions src/components/task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default {
initialRequestId: { type: Number, default: null },
initialProcessId: { type: Number, default: null },
initialNodeId: { type: String, default: null },
screenVersion: { type: Number, default: null },
userId: { type: Number, default: null },
csrfToken: { type: String, default: null },
value: { type: Object, default: () => {} },
Expand Down Expand Up @@ -261,12 +262,17 @@ export default {
this.loadNextAssignedTask();
}
},
loadTask() {
loadTask(mounting = false) {
if (!this.taskId) {
return;
}
const url = `/${this.taskId}?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination`;
let url = `/${this.taskId}?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission,elementDestination`;
if (this.screenVersion) {
url += `&screen_version=${this.screenVersion}`;
}
// For Vocabularies
if (window.ProcessMaker && window.ProcessMaker.packages && window.ProcessMaker.packages.includes('package-vocabularies')) {
window.ProcessMaker.VocabulariesSchemaUrl = `vocabularies/task_schema/${this.taskId}`;
Expand All @@ -277,7 +283,7 @@ export default {
.getTasks(url)
.then((response) => {
this.task = response.data;
this.linkTask();
this.linkTask(mounting);
this.checkTaskStatus();
if (
window.PM4ConfigOverrides
Expand All @@ -297,12 +303,27 @@ export default {
});
});
},
linkTask() {
linkTask(mounting) {
this.nodeId = this.task.element_id;
this.listenForParentChanges();
if (this.task.process_request.status === 'COMPLETED') {
if (!this.taskPreview) {
this.$emit('completed', this.task.process_request.id);
// When the process ends before the request is opened
if (mounting) {
// get end event element destination config
window.ProcessMaker.apiClient.get(`/requests/${this.requestId}/end-event-destination`)
.then((response) => {
if (!response.data?.data?.endEventDestination) {
// by default it goes to summary
window.location.href = `/requests/${this.requestId}`;
return;
}
// process the end event destination
this.processCompletedRedirect(response.data.data, this.userId, this.requestId);
});
}
}
}
if (this.taskPreview && this.task.status === "CLOSED") {
Expand Down Expand Up @@ -518,6 +539,7 @@ export default {
} else if (this.parentRequest && ['COMPLETED', 'CLOSED'].includes(this.task.process_request.status)) {
this.$emit('completed', this.getAllowedRequestId());
}
this.disabled = false;
});
},
emitIfTaskCompleted(requestId) {
Expand Down Expand Up @@ -827,9 +849,9 @@ export default {
*/
isSameUser(currentTask, redirectData) {
const userIdMatch = currentTask.user?.id === redirectData.params[0].userId;
const typeMatch = currentTask.elementDestination?.type === null
const typeMatch = currentTask.elementDestination?.type === null
|| currentTask.elementDestination?.type === 'taskSource';
return userIdMatch && typeMatch;
},
Expand All @@ -840,6 +862,17 @@ export default {
* @param {Object} data - The event data containing the process update information.
*/
handleProcessUpdated(data) {
const elementDestinationValue = this.task.elementDestination?.value;
if (
elementDestinationValue &&
data?.params[0]?.tokenId === this.taskId &&
data?.params[0]?.requestStatus === 'ACTIVE'
) {
window.location.href = elementDestinationValue;
return;
}
if (
['ACTIVITY_ACTIVATED', 'ACTIVITY_COMPLETED'].includes(data.event)
&& data.elementType === 'task'
Expand Down Expand Up @@ -968,7 +1001,8 @@ export default {
this.nodeId = this.initialNodeId;
this.requestData = this.value;
this.loopContext = this.initialLoopContext;
this.loadTask();
this.loadTask(true);
this.setSelfService();
},
destroyed() {
this.unsubscribeSocketListeners();
Expand Down

0 comments on commit 97354cb

Please sign in to comment.