@oat-sa/tao-core-ui 3.21.0 → 3.21.1

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.
@@ -87,9 +87,28 @@ define(['jquery', 'lodash', 'i18n', 'ui/report', 'ui/feedback', 'layout/loading-
87
87
  loadingBar.start();
88
88
  taskQueue.pollAllStop();
89
89
  taskQueue.create(requestUrl, requestData).then(function (result) {
90
- var infoBox,
91
- message,
90
+ var message,
92
91
  task = result.task;
92
+
93
+ /**
94
+ * Creates feedback box and notifies task queue listeners.
95
+ * @param {Object} taskData
96
+ * @param {String} feedbackMessage
97
+ * @param {String} feedbackType
98
+ * @returns {void}
99
+ */
100
+ var notifyTaskCreated = function notifyTaskCreated(taskData, feedbackMessage, feedbackType) {
101
+ var box = feedback(null, {
102
+ encodeHtml: false,
103
+ timeout: {
104
+ [feedbackType]: 8000
105
+ }
106
+ })[feedbackType](feedbackMessage);
107
+ taskQueue.trigger('taskcreated', {
108
+ task: taskData,
109
+ sourceDom: box.getElement()
110
+ });
111
+ };
93
112
  if (result.finished) {
94
113
  if (task.hasFile) {
95
114
  //download if its is a export-typed task
@@ -104,7 +123,8 @@ define(['jquery', 'lodash', 'i18n', 'ui/report', 'ui/feedback', 'layout/loading-
104
123
  taskQueue.pollAll();
105
124
  });
106
125
  } else {
107
- //immediately archive the finished task as there is no need to display this task in the queue list
126
+ message = __('<strong> %s </strong> has been completed.', _.escape(task.taskLabel));
127
+ notifyTaskCreated(task, message, 'success');
108
128
  taskQueue.archive(task.id).then(function () {
109
129
  self.trigger('finished', result);
110
130
  taskQueue.pollAll();
@@ -115,17 +135,8 @@ define(['jquery', 'lodash', 'i18n', 'ui/report', 'ui/feedback', 'layout/loading-
115
135
  }
116
136
  } else {
117
137
  //enqueuing process:
118
- message = __('<strong> %s </strong> has been moved to the background.', task.taskLabel);
119
- infoBox = feedback(null, {
120
- encodeHtml: false,
121
- timeout: {
122
- info: 8000
123
- }
124
- }).info(message);
125
- taskQueue.trigger('taskcreated', {
126
- task: task,
127
- sourceDom: infoBox.getElement()
128
- });
138
+ message = __('<strong> %s </strong> has been moved to the background.', _.escape(task.taskLabel));
139
+ notifyTaskCreated(task, message, 'info');
129
140
  self.trigger('enqueued', result);
130
141
  }
131
142
  loadingBar.stop();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oat-sa/tao-core-ui",
3
- "version": "3.21.0",
3
+ "version": "3.21.1",
4
4
  "displayName": "TAO Core UI",
5
5
  "description": "UI libraries of TAO",
6
6
  "scripts": {
@@ -86,10 +86,25 @@ var taskableComponent = {
86
86
  taskQueue
87
87
  .create(requestUrl, requestData)
88
88
  .then(function(result) {
89
- var infoBox,
90
- message,
89
+ var message,
91
90
  task = result.task;
92
91
 
92
+ /**
93
+ * Creates feedback box and notifies task queue listeners.
94
+ * @param {Object} taskData
95
+ * @param {String} feedbackMessage
96
+ * @param {String} feedbackType
97
+ * @returns {void}
98
+ */
99
+ var notifyTaskCreated = function notifyTaskCreated(taskData, feedbackMessage, feedbackType) {
100
+ var box = feedback(null, {
101
+ encodeHtml: false,
102
+ timeout: { [feedbackType]: 8000 }
103
+ })[feedbackType](feedbackMessage);
104
+
105
+ taskQueue.trigger('taskcreated', { task: taskData, sourceDom: box.getElement() });
106
+ };
107
+
93
108
  if (result.finished) {
94
109
  if (task.hasFile) {
95
110
  //download if its is a export-typed task
@@ -108,7 +123,8 @@ var taskableComponent = {
108
123
  taskQueue.pollAll();
109
124
  });
110
125
  } else {
111
- //immediately archive the finished task as there is no need to display this task in the queue list
126
+ message = __('<strong> %s </strong> has been completed.', _.escape(task.taskLabel));
127
+ notifyTaskCreated(task, message, 'success');
112
128
  taskQueue
113
129
  .archive(task.id)
114
130
  .then(function() {
@@ -122,13 +138,8 @@ var taskableComponent = {
122
138
  }
123
139
  } else {
124
140
  //enqueuing process:
125
- message = __('<strong> %s </strong> has been moved to the background.', task.taskLabel);
126
- infoBox = feedback(null, {
127
- encodeHtml: false,
128
- timeout: { info: 8000 }
129
- }).info(message);
130
-
131
- taskQueue.trigger('taskcreated', { task: task, sourceDom: infoBox.getElement() });
141
+ message = __('<strong> %s </strong> has been moved to the background.', _.escape(task.taskLabel));
142
+ notifyTaskCreated(task, message, 'info');
132
143
  self.trigger('enqueued', result);
133
144
  }
134
145
  loadingBar.stop();