@raketa-cloud/admin 1.8.22 → 1.8.23

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-cloud/admin",
3
- "version": "1.8.22",
3
+ "version": "1.8.23",
4
4
  "main": "src/index.js",
5
5
  "files": [
6
6
  "src/",
@@ -107,6 +107,7 @@ const create = async (ctx) => {
107
107
  resource: {
108
108
  translations: blueprint.translations || {},
109
109
  languages: [],
110
+ workflow: ctx.resourceParams?.resource?.workflow,
110
111
  },
111
112
  blueprint,
112
113
  targetLocale: originalLocale,
@@ -167,6 +168,7 @@ const create = async (ctx) => {
167
168
  ...resource,
168
169
  translations: blueprint.translations || {},
169
170
  languages: formLanguages,
171
+ workflow: workflow,
170
172
  },
171
173
  blueprint,
172
174
  targetLocale: originalLocale,
@@ -211,6 +213,7 @@ const create = async (ctx) => {
211
213
  ...resource,
212
214
  translations: blueprint.translations || {},
213
215
  languages: formLanguages,
216
+ workflow: workflow,
214
217
  },
215
218
  blueprint,
216
219
  targetLocale: locale,
@@ -36,15 +36,15 @@
36
36
  <select name="resource[workflow][type]" id="workflow">
37
37
  <option value="">Default (no workflow)</option>
38
38
 
39
- <option value="LOKALISE_TO_AI_RT_HUM" <%= resource.workflow === 'LOKALISE_TO_AI_RT_HUM' ? 'selected' : '' %>>
39
+ <option value="LOKALISE_TO_AI_RT_HUM" <%= resource.workflow?.type === 'LOKALISE_TO_AI_RT_HUM' ? 'selected' : '' %>>
40
40
  <%= content_tasks.workflowsMap("LOKALISE_TO_AI_RT_HUM".toLowerCase()) %>
41
41
  </option>
42
42
 
43
- <option value="LOKALISE_TT_HUM" <%= resource.workflow === 'LOKALISE_TT_HUM' ? 'selected' : '' %>>
43
+ <option value="LOKALISE_TT_HUM" <%= resource.workflow?.type === 'LOKALISE_TT_HUM' ? 'selected' : '' %>>
44
44
  <%= content_tasks.workflowsMap("LOKALISE_TT_HUM".toLowerCase()) %>
45
45
  </option>
46
46
 
47
- <option value="LOKALISE_TT_AI" <%= resource.workflow === 'LOKALISE_TT_AI' ? 'selected' : '' %>>
47
+ <option value="LOKALISE_TT_AI" <%= resource.workflow?.type === 'LOKALISE_TT_AI' ? 'selected' : '' %>>
48
48
  <%= content_tasks.workflowsMap("LOKALISE_TT_AI".toLowerCase()) %>
49
49
  </option>
50
50
  </select>
@@ -55,49 +55,85 @@
55
55
 
56
56
  <div class="mb-4" id="due_date_wrapper">
57
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" />
58
+ <input type="datetime-local" name="resource[workflow][due_date]" id="due_date" value="<%= resource.workflow?.due_date || "" %>" />
59
+
59
60
  <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
+ Select a due date for the translation. Weekends are not a valid choice.
61
62
  </p>
62
63
  </div>
63
64
 
64
65
  <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;
66
+ window.addEventListener("load", (_event) => {
67
+ (function () {
68
+ const workflowSelect = document.getElementById("workflow");
69
+ const dueDateWrapper = document.getElementById("due_date_wrapper");
70
+ const dueDateInput = document.getElementById("due_date");
71
+
72
+ function validateInputValue(dInput) {
73
+ if (dInput.value === "") {
74
+ dInput.setCustomValidity('');
75
+ return;
76
+ }
77
+
78
+ const selectedDate = new Date(dInput.value);
79
+ const day = selectedDate.getDay();
80
+
81
+ if (day === 0 || day === 6) {
82
+ dInput.setCustomValidity('Weekends are not allowed. Please select a weekday.')
83
+ selectedDate.value = '';
84
+ } else {
85
+ dInput.setCustomValidity('');
86
+ }
93
87
  }
94
- }
95
88
 
96
- if (workflowSelect) {
97
- workflowSelect.addEventListener("change", toggleDueDate);
98
- toggleDueDate();
99
- }
100
- })();
89
+ dueDateInput.addEventListener('change', function(e) {
90
+ validateInputValue(dueDateInput);
91
+ });
92
+
93
+ function getTwoDaysFromNowString() {
94
+ const date = new Date();
95
+
96
+
97
+ date.setDate(date.getDate() + 2);
98
+
99
+ // Skip weekends.
100
+ while(date.getDay() === 0 || date.getDay() === 6) {
101
+ date.setDate(date.getDate() + 1);
102
+ }
103
+
104
+ const year = date.getFullYear();
105
+ const month = String(date.getMonth() + 1).padStart(2, "0");
106
+ const day = String(date.getDate()).padStart(2, "0");
107
+ const hours = String(date.getHours()).padStart(2, "0");
108
+ const minutes = String(date.getMinutes()).padStart(2, "0");
109
+ return `${year}-${month}-${day}T${hours}:${minutes}`;
110
+ }
111
+
112
+ function toggleDueDate() {
113
+ if (!workflowSelect || !dueDateWrapper || !dueDateInput) return;
114
+ const minDate = getTwoDaysFromNowString();
115
+ dueDateInput.min = minDate;
116
+
117
+ const isDefault = !workflowSelect.value;
118
+ dueDateWrapper.style.display = isDefault ? "none" : "block";
119
+
120
+ if (isDefault) {
121
+ dueDateInput.value = "";
122
+ } else if (!dueDateInput.value) {
123
+ dueDateInput.value = minDate;
124
+ }
125
+
126
+ // Trigger the on change so hints are visible together with the validation.
127
+ const changeEvent = new Event('change', { bubbles: true });
128
+ dueDateInput.dispatchEvent(changeEvent);
129
+ }
130
+
131
+ if (workflowSelect) {
132
+ workflowSelect.addEventListener("change", toggleDueDate);
133
+ toggleDueDate();
134
+ }
135
+ })();
136
+ })
101
137
  </script>
102
138
  <% } %>
103
139