@raketa-cloud/admin 1.8.19 → 1.8.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/cloud/Resources.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toDateInput, toDateTimeInput } from "../utils";
|
|
1
|
+
import { toDateInput, toDateTimeInput, toUTCISO8601String } from "../utils";
|
|
2
2
|
import RaketaClient from "./RaketaClient";
|
|
3
3
|
import {
|
|
4
4
|
ChangeResourceSlugDocument,
|
|
@@ -155,6 +155,20 @@ export default class Resources extends RaketaClient {
|
|
|
155
155
|
return { resource, errors };
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
appendWorkflow(input, workflow) {
|
|
159
|
+
if (!workflow?.type) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
input.workflow = {
|
|
164
|
+
type: workflow.type,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
if (workflow.due_date) {
|
|
168
|
+
input.workflow.dueDate = toUTCISO8601String(workflow.due_date);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
158
172
|
async translateBatch(
|
|
159
173
|
sourceResourceId,
|
|
160
174
|
locales,
|
|
@@ -178,9 +192,7 @@ export default class Resources extends RaketaClient {
|
|
|
178
192
|
resource: paramsCopy,
|
|
179
193
|
};
|
|
180
194
|
|
|
181
|
-
|
|
182
|
-
input.workflow = workflow;
|
|
183
|
-
}
|
|
195
|
+
this.appendWorkflow(input, workflow);
|
|
184
196
|
|
|
185
197
|
variables[`input${i}`] = input;
|
|
186
198
|
});
|
|
@@ -141,7 +141,9 @@ describe("Resource Translations Handler create", () => {
|
|
|
141
141
|
|
|
142
142
|
const ctx = buildCtx({
|
|
143
143
|
resource: blueprint,
|
|
144
|
-
resourceParams: {
|
|
144
|
+
resourceParams: {
|
|
145
|
+
resource: { languages: ["fr"], workflow: { type: "lokalise" } },
|
|
146
|
+
},
|
|
145
147
|
});
|
|
146
148
|
|
|
147
149
|
jest
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
<% if (utils.feature("contentTasks", _context) && _context.locale === _context.defaultLocale) { %>
|
|
34
34
|
<div class="mb-4">
|
|
35
35
|
<label for="workflow" class="font-semibold hover:cursor-pointer body-3">Translation workflow</label>
|
|
36
|
-
<select name="resource[workflow]" id="workflow">
|
|
36
|
+
<select name="resource[workflow][type]" id="workflow">
|
|
37
37
|
<option value="">Default (no workflow)</option>
|
|
38
38
|
|
|
39
39
|
<option value="LOKALISE_TO_AI_RT_HUM" <%= resource.workflow === 'LOKALISE_TO_AI_RT_HUM' ? 'selected' : '' %>>
|
|
@@ -52,6 +52,53 @@
|
|
|
52
52
|
Select a workflow for the translation process. Lokalise workflow initiates a translation task for external translation.
|
|
53
53
|
</p>
|
|
54
54
|
</div>
|
|
55
|
+
|
|
56
|
+
<div class="mb-4" id="due_date_wrapper">
|
|
57
|
+
<label for="due_date" class="font-semibold hover:cursor-pointer body-3">Due date (UTC)</label>
|
|
58
|
+
<input type="datetime-local" name="resource[workflow][due_date]" id="due_date" />
|
|
59
|
+
<p class="text-sm text-raketa-foreground/50 mt-1">
|
|
60
|
+
Select a workflow for the translation process. Lokalise workflow initiates a translation task for external translation.
|
|
61
|
+
</p>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<script>
|
|
65
|
+
(function () {
|
|
66
|
+
const workflowSelect = document.getElementById("workflow");
|
|
67
|
+
const dueDateWrapper = document.getElementById("due_date_wrapper");
|
|
68
|
+
const dueDateInput = document.getElementById("due_date");
|
|
69
|
+
|
|
70
|
+
function getTwoDaysFromNowString() {
|
|
71
|
+
const date = new Date();
|
|
72
|
+
date.setDate(date.getDate() + 2);
|
|
73
|
+
const year = date.getFullYear();
|
|
74
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
75
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
76
|
+
const hours = String(date.getHours()).padStart(2, "0");
|
|
77
|
+
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
78
|
+
return `${year}-${month}-${day}T${hours}:${minutes}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function toggleDueDate() {
|
|
82
|
+
if (!workflowSelect || !dueDateWrapper || !dueDateInput) return;
|
|
83
|
+
const minDate = getTwoDaysFromNowString();
|
|
84
|
+
dueDateInput.min = minDate;
|
|
85
|
+
|
|
86
|
+
const isDefault = !workflowSelect.value;
|
|
87
|
+
dueDateWrapper.style.display = isDefault ? "none" : "block";
|
|
88
|
+
|
|
89
|
+
if (isDefault) {
|
|
90
|
+
dueDateInput.value = "";
|
|
91
|
+
} else if (!dueDateInput.value) {
|
|
92
|
+
dueDateInput.value = minDate;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (workflowSelect) {
|
|
97
|
+
workflowSelect.addEventListener("change", toggleDueDate);
|
|
98
|
+
toggleDueDate();
|
|
99
|
+
}
|
|
100
|
+
})();
|
|
101
|
+
</script>
|
|
55
102
|
<% } %>
|
|
56
103
|
|
|
57
104
|
<% if (errors?.resource && targetLocale) { %>
|