infopark_fiona7 1.5.5.5.1 → 1.6.1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +17 -0
  3. data/app/assets/javascripts/fiona7/task_list_dialog.js +2 -2
  4. data/app/assets/javascripts/fiona7/templates.js +1 -16
  5. data/app/assets/javascripts/fiona7/translations.js +22 -23
  6. data/app/assets/javascripts/fiona7_ui.js +56 -59
  7. data/app/assets/javascripts/scrivito_patches/base_obj_path.js +11 -5
  8. data/app/assets/javascripts/scrivito_patches/binary_request.js +53 -0
  9. data/app/assets/javascripts/scrivito_patches/client/ajax.js +122 -0
  10. data/app/assets/javascripts/scrivito_patches/{models/api → client}/basic_obj.js +150 -243
  11. data/app/assets/javascripts/scrivito_patches/client/cms_rest_api.js +209 -0
  12. data/app/assets/javascripts/scrivito_patches/components/sidebar/workspaces_panel.js +325 -0
  13. data/app/assets/javascripts/scrivito_patches/components/sidebar/workspaces_panel.js.jsx +294 -0
  14. data/app/assets/javascripts/scrivito_patches/models/{obj.js → legacy_obj.js} +27 -54
  15. data/app/assets/stylesheets/fiona7_ui.css.scss +2 -0
  16. data/app/controllers/fiona7/release_controller.rb +7 -6
  17. data/app/controllers/fiona7/sessions_controller.rb +10 -2
  18. data/app/controllers/fiona7/uploads_controller.rb +22 -0
  19. data/app/controllers/fiona7_login_page_controller.rb +3 -0
  20. data/app/controllers/scrivito/obj_class_controller.rb +28 -5
  21. data/app/views/fiona7/release/preview.html.erb +5 -38
  22. data/app/views/fiona7_login_page/index.html.erb +6 -0
  23. data/config/precedence_routes.rb +7 -7
  24. data/infopark_fiona7.gemspec +2 -2
  25. data/lib/fiona7/attribute_readers/number_as_string.rb +6 -1
  26. data/lib/fiona7/attribute_writers/binary_as_binary.rb +4 -2
  27. data/lib/fiona7/attribute_writers/binary_as_linklist.rb +4 -2
  28. data/lib/fiona7/builder/container_chain_builder.rb +50 -0
  29. data/lib/fiona7/builder/indirect_blob_builder.rb +7 -47
  30. data/lib/fiona7/builder/indirect_blob_builder_for_obj.rb +14 -0
  31. data/lib/fiona7/builder/lazy_blob_copier.rb +68 -14
  32. data/lib/fiona7/builder/obj_builder.rb +6 -32
  33. data/lib/fiona7/builder/obj_updater.rb +12 -4
  34. data/lib/fiona7/builder/widget_builder.rb +1 -1
  35. data/lib/fiona7/controllers/rest_api/blob_controller.rb +8 -2
  36. data/lib/fiona7/controllers/rest_api/obj_controller.rb +12 -8
  37. data/lib/fiona7/controllers/rest_api/workspace_controller.rb +6 -0
  38. data/lib/fiona7/engine.rb +49 -3
  39. data/lib/fiona7/forbidden_obj_classes.rb +14 -3
  40. data/lib/fiona7/linked_id_finder.rb +44 -0
  41. data/lib/fiona7/name_and_parent_from_path.rb +11 -0
  42. data/lib/fiona7/referenced_id_finder.rb +24 -0
  43. data/lib/fiona7/release_collector.rb +85 -0
  44. data/lib/fiona7/routers/rest_api.rb +2 -0
  45. data/lib/fiona7/scrivito_patches/cms_field_tag.rb +1 -0
  46. data/lib/fiona7/scrivito_patches/cms_rest_api.rb +16 -16
  47. data/lib/fiona7/scrivito_patches/cms_routing.rb +1 -0
  48. data/lib/fiona7/scrivito_patches/link_parser.rb +10 -7
  49. data/lib/fiona7/scrivito_patches/workspace.rb +0 -5
  50. data/lib/fiona7/super_id_finder.rb +68 -0
  51. data/lib/fiona7/super_object_finder.rb +5 -20
  52. data/lib/fiona7/temporary_uploader.rb +33 -0
  53. data/lib/fiona7/upload_path_selector.rb +17 -0
  54. data/lib/fiona7/verity_search_engine.rb +25 -12
  55. data/lib/fiona7/version.rb +1 -1
  56. metadata +23 -19
  57. data/app/assets/javascripts/fiona7/task_list_command.js +0 -15
  58. data/app/assets/javascripts/fiona7/task_list_menu_item.js +0 -30
  59. data/app/assets/javascripts/scrivito_patches/ajax.js +0 -225
  60. data/app/assets/javascripts/scrivito_patches/attribute_serializer.js +0 -259
  61. data/app/assets/javascripts/scrivito_patches/binary_utils.js +0 -33
  62. data/app/assets/javascripts/scrivito_patches/cms_rest_api.js +0 -371
  63. data/app/assets/javascripts/scrivito_patches/models/binary_field_element.js +0 -53
  64. data/app/assets/javascripts/scrivito_patches/obj_serializer.js +0 -91
  65. data/lib/fiona7/scrivito_patches/attribute_serializer.rb +0 -37
  66. data/lib/fiona7/scrivito_patches/model_library.rb +0 -19
  67. data/lib/fiona7/scrivito_patches/obj_params_parser.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 177ce65e32ed0f678d47597707dac7ba6c92fe38
4
- data.tar.gz: 76004b87e5ef7a1ebb67a70b9f237569ac19ec39
3
+ metadata.gz: cd5af32d592de98bf21bad9ae13300a9c5a17786
4
+ data.tar.gz: 45b0946e073a24b93b2b418770c8de7eee312889
5
5
  SHA512:
6
- metadata.gz: 92e28bf2c4f333be21b7e7fcc4b95bbea8848b273ff46fdd3059cf3f1c174cf1cd67f9e7ac2ac1dfae2637e7bb6b129127b2d2995de34ea0e2577351d0c5cc58
7
- data.tar.gz: d4ab26477bc1c9e1b4e6f0a4dc3ae292ed861a65bffdd4bb0b30f12afd7e2228a4bc60442f5b237fe95c8b171c20fe02cf1e59b4a4addf5b254774ab2609f46a
6
+ metadata.gz: 1e33280b118ab2e9b6b023450be624fc0f223f8e894195493aa6aa342d7ab937e23b58bf8dd0d0910bc8e4cd4a4e17951d894c1d39b27b4fa45492c12fe29af3
7
+ data.tar.gz: 26841cfc7effbc06117518a6e2e1585ae44dbaf5534749015c3e8bcdf76ca7a9e07b87534ded47391e96caef0cdfbb13467bcd15bd63d659e54bcc7f263f04a4
data/Rakefile CHANGED
@@ -30,6 +30,14 @@ namespace "package" do
30
30
  f.write Babel::Transpiler.transform(File.read(fname))["code"]
31
31
  end
32
32
  end
33
+
34
+ if /\.js\.jsx$/ =~ fname
35
+ nfname = ::File.join(::File.dirname(fname), ::File.basename(fname, '.js.jsx') + '.js')
36
+ puts "#{fname} -> #{nfname}"
37
+ ::File.open(nfname, 'w') do |f|
38
+ f.write Babel::Transpiler.transform(File.read(fname))["code"]
39
+ end
40
+ end
33
41
  end
34
42
  puts "Processing handlebars templates"
35
43
  templates = []
@@ -71,6 +79,11 @@ namespace "clean" do
71
79
  puts "#{nfname}"
72
80
  ::FileUtils.rm(nfname) if ::File.exists?(nfname)
73
81
  end
82
+ if /\.js\.jsx$/ =~ fname
83
+ nfname = ::File.join(::File.dirname(fname), ::File.basename(fname, '.js.jsx') + '.js')
84
+ puts "#{nfname}"
85
+ ::FileUtils.rm(nfname) if ::File.exists?(nfname)
86
+ end
74
87
  end
75
88
  end
76
89
  end
@@ -81,3 +94,7 @@ end
81
94
 
82
95
  Bundler::GemHelper.install_tasks
83
96
 
97
+
98
+ task "build" => ["clean:js"] do
99
+ # dummy, needed to clean-up
100
+ end
@@ -41,7 +41,7 @@
41
41
 
42
42
  _.each(tasks, function(task) {
43
43
  task.obj_data = task.obj;
44
- task.obj = scrivito.obj.create_instance(task.obj);
44
+ task.obj = scrivito.legacy_obj.create_instance(task.obj);
45
45
  task.last_changed = string_date_to_function(task.last_changed);
46
46
  });
47
47
 
@@ -51,7 +51,7 @@
51
51
 
52
52
  var string_date_to_function = function(string_date) {
53
53
  return function() {
54
- return scrivito.parseDate(string_date);
54
+ return scrivito.types.deserializeAsDate(string_date);
55
55
  };
56
56
  };
57
57
 
@@ -73,7 +73,7 @@
73
73
  + "\n </span>\n </td>\n\n <td>\n <span>\n <time datetime=\""
74
74
  + container.escapeExpression(((helper = (helper = helpers.last_changed || (depth0 != null ? depth0.last_changed : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"last_changed","hash":{},"data":data}) : helper)))
75
75
  + "\" title=\""
76
- + container.escapeExpression((helpers.localize_date || (depth0 && depth0.localize_date) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.last_changed : depth0),{"name":"localize_date","hash":{},"data":data}))
76
+ + container.escapeExpression((helpers.localizeDate || (depth0 && depth0.localizeDate) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.last_changed : depth0),{"name":"localizeDate","hash":{},"data":data}))
77
77
  + "\">\n "
78
78
  + container.escapeExpression((helpers.localizeDateRelative || (depth0 && depth0.localizeDateRelative) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.last_changed : depth0),{"name":"localizeDateRelative","hash":{},"data":data}))
79
79
  + "\n </time>\n </span>\n </td>\n</tr>\n";
@@ -89,18 +89,3 @@
89
89
  },"useData":true});
90
90
  return this.ScrivitoHandlebarsTemplates["task_list_dialog"];
91
91
  }).call(this);
92
- (function() {
93
- this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {});
94
- this.ScrivitoHandlebarsTemplates["task_list_menu_item"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
95
- var stack1, helper;
96
-
97
- return "<li id=\"fiona7_task_list\" class=\"scrivito_menu_item fiona7_task_list\">\n<span title=\""
98
- + container.escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"title","hash":{},"data":data}) : helper)))
99
- + "\"><i class=\"scrivito_icon\">"
100
- + ((stack1 = ((helper = (helper = helpers.icon || (depth0 != null ? depth0.icon : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"icon","hash":{},"data":data}) : helper))) != null ? stack1 : "")
101
- + "</i> "
102
- + container.escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"title","hash":{},"data":data}) : helper)))
103
- + " </span>\n</li>\n";
104
- },"useData":true});
105
- return this.ScrivitoHandlebarsTemplates["task_list_menu_item"];
106
- }).call(this);
@@ -1,5 +1,5 @@
1
1
  (function() {
2
- $.i18n().load({
2
+ scrivito.i18n.load('de', {
3
3
  'commands.release_obj.title': 'Seite freigeben',
4
4
  'commands.release_obj.not_modified_obj': 'Diese Seite wurde nicht geändert. Daher gibt es nichts zu freigeben.',
5
5
  'commands.release_obj.dialog.title': 'Änderungen an dieser Seite veröffentlichen?',
@@ -51,10 +51,22 @@
51
51
  'commands.take_obj.failed': 'Übernahme fehlgeschlagen',
52
52
 
53
53
  'editing_disabled.workflow': 'Die Datei unterliegt einem Workflow und kann nicht direkt bearbeitet werden.',
54
- 'editing_disabled.permissions': 'Ihnen fehlen die Rechte um die Datei zu bearbeiten'
55
- }, 'de');
54
+ 'editing_disabled.permissions': 'Ihnen fehlen die Rechte um die Datei zu bearbeiten',
55
+ 'commands.task_list.title': 'Aufgaben anzeigen',
56
+ 'task_list_dialog.title.all': 'Aufgaben anzeigen: alle Aufgaben',
57
+ 'task_list_dialog.title.user': 'Aufgaben anzeigen: meine Aufgaben',
58
+ 'task_list_dialog.mode_toggle.all': 'Meine Aufgaben anzeigen',
59
+ 'task_list_dialog.mode_toggle.user': 'Alle Aufgaben anzeigen',
60
+ 'task_list_dialog.user_login': 'Benutzer',
61
+ 'task_list_dialog.group_name': 'Gruppe',
62
+ 'task_list_dialog.comment': 'Kommentar',
63
+ 'task_list_dialog.empty': 'Keine Aufgaben',
64
+ 'sidebar.workspaces_panel.tasks_button.title': 'Aufgaben',
65
+ 'sidebar.workspaces_panel.tasks_button.hint': 'Aufgabendialog anzeigen',
66
+ 'sidebar.workspaces_panel.tasks_button.is_forbidden': 'Aufgaben können aufgrund fehlender Benutzerrechte nicht angezeigt werden.',
67
+ });
56
68
 
57
- $.i18n().load({
69
+ scrivito.i18n.load('en', {
58
70
  'commands.release_obj.title': 'Release page',
59
71
  'commands.release_obj.not_modified_obj': 'This resource has not been modified. Therefore, nothing can be released.',
60
72
  'commands.release_obj.dialog.title': 'Release this page?',
@@ -106,22 +118,7 @@
106
118
  'commands.take_obj.failed': 'Take failed',
107
119
 
108
120
  'editing_disabled.workflow': 'The current page belongs to a workflow and cannot be edited directly.',
109
- 'editing_disabled.permissions': 'You do not have the permissions required to edit this page.'
110
- }, 'en');
111
-
112
- $.i18n().load({
113
- 'commands.task_list.title': 'Aufgaben anzeigen',
114
- 'task_list_dialog.title.all': 'Aufgaben anzeigen: alle Aufgaben',
115
- 'task_list_dialog.title.user': 'Aufgaben anzeigen: meine Aufgaben',
116
- 'task_list_dialog.mode_toggle.all': 'Meine Aufgaben anzeigen',
117
- 'task_list_dialog.mode_toggle.user': 'Alle Aufgaben anzeigen',
118
- 'task_list_dialog.user_login': 'Benutzer',
119
- 'task_list_dialog.group_name': 'Gruppe',
120
- 'task_list_dialog.comment': 'Kommentar',
121
- 'task_list_dialog.empty': 'Keine Aufgaben'
122
- }, 'de');
123
-
124
- $.i18n().load({
121
+ 'editing_disabled.permissions': 'You do not have the permissions required to edit this page.',
125
122
  'commands.task_list.title': 'Task list',
126
123
  'task_list_dialog.title.all': 'Task list: All tasks',
127
124
  'task_list_dialog.title.user': 'Task list: My tasks',
@@ -130,7 +127,9 @@
130
127
  'task_list_dialog.user_login': 'User',
131
128
  'task_list_dialog.group_name': 'Receiving group',
132
129
  'task_list_dialog.comment': 'Comment',
133
- 'task_list_dialog.empty': 'No taks'
134
- }, 'en');
135
-
130
+ 'task_list_dialog.empty': 'No tasks',
131
+ 'sidebar.workspaces_panel.tasks_button.title': 'Tasks',
132
+ 'sidebar.workspaces_panel.tasks_button.hint': 'Open the tasks dialog',
133
+ 'sidebar.workspaces_panel.tasks_button.is_forbidden': 'You cannot open the tasks dialog due to missing user permissions.',
134
+ });
136
135
  }());
@@ -1,18 +1,7 @@
1
- //= require scrivito_patches/models/api/basic_obj
2
- //= require scrivito_patches/models/binary_field_element
3
- //= require scrivito_patches/models/obj
4
- //= require scrivito_patches/ajax
5
- //= require scrivito_patches/attribute_serializer
6
- //= require scrivito_patches/ajax_error_handling
7
- //= require scrivito_patches/base_obj_path
8
- //= require scrivito_patches/cms_rest_api
9
- //= require scrivito_patches/obj_serializer
10
- //= require scrivito_patches/binary_utils
1
+ //= require_tree ./scrivito_patches
11
2
  //= require fiona7/translations
12
3
  //= require fiona7/templates
13
4
  //= require fiona7/task_list_dialog
14
- //= require fiona7/task_list_command
15
- //= require fiona7/task_list_menu_item
16
5
  //= require_self
17
6
 
18
7
  (function() {
@@ -21,27 +10,9 @@
21
10
  var $ = window.$;
22
11
 
23
12
  scrivito.gui.on('open', function() {
24
- scrivito.task_list_menu_item.init();
13
+ //scrivito.task_list_menu_item.init();
25
14
  });
26
15
 
27
- var original_create_instance = scrivito.child_list_element.create_instance;
28
-
29
- /* patch the create page command to not create incomprehensible paths */
30
- scrivito.child_list_element.create_instance = function(cms_element) {
31
- var ret = original_create_instance.call(this, cms_element);
32
- if (typeof ret === "object") {
33
- ret.create_child = function(obj_class) {
34
- var path = (cms_element.path() + '/' + obj_class).replace(/\/\//g, "/");
35
-
36
- return scrivito.obj.create({
37
- _path: path,
38
- _obj_class: obj_class
39
- });
40
- };
41
- }
42
- return ret;
43
- };
44
-
45
16
  var open_confirmation_dialog = function(action,icon) {
46
17
  return scrivito.prompt_dialog({
47
18
  title: scrivito.t('commands.'+action+'_obj.dialog.title'),
@@ -133,28 +104,48 @@
133
104
  };
134
105
  var actions = ["edit", "forward", "reject","commit", "sign", "take"];
135
106
 
136
- var releaseAction = function (objId) {
107
+ var reloadWholePage = function () {
108
+ return scrivito.withSavingOverlay(scrivito.reload());
109
+ };
110
+
111
+ var pageActionComplete = function (action) {
112
+ if (action == 'edit' || action == 'take') {
113
+ return function () {
114
+ if (!scrivito.editingContext.isEditingMode()) {
115
+ return scrivito.withSavingOverlay(
116
+ scrivito.changeEditingContext({display_mode: 'editing', workspace_id: 'rtc'}));
117
+ } else {
118
+ return reloadWholePage();
119
+ }
120
+ };
121
+ } else {
122
+ // NOTE: no call here, just function returned
123
+ return reloadWholePage;
124
+ }
125
+ };
126
+
127
+ var reloadGivenWindow = function(targetWindow) {
128
+ return function () {
129
+ if (targetWindow && targetWindow.location) {
130
+ // forgo cache
131
+ targetWindow.location.reload(true);
132
+ }
133
+ };
134
+ };
135
+
136
+ var releaseAction = function (objId, reloadFunction) {
137
+ reloadFunction = reloadFunction || reloadWholePage;
138
+
137
139
  open_release_dialog(objId).done(function(objIds, comment) {
138
- scrivito.withSavingOverlay(scrivito.ajax('PUT', 'objs/release', {data: {objs: objIds, comment: comment}}).then(function() {
139
- scrivito.reload();
140
- }));
140
+ scrivito.withSavingOverlay(scrivito.ajax('PUT', 'objs/release', {data: {objs: objIds, comment: comment}}).then(reloadFunction));
141
141
  });
142
142
  };
143
143
 
144
- var workflowAction = function (action, objId) {
144
+ var workflowAction = function (action, objId, reloadFunction) {
145
+ reloadFunction = reloadFunction || pageActionComplete(action);
146
+
145
147
  open_confirmation_dialog(action, dialog_icons[action]).done(function(comment) {
146
- scrivito.withSavingOverlay(scrivito.ajax('PUT', 'objs/workflow/'+action, {data: {id: objId, comment: comment}}).then(function() {
147
- if (action == 'edit' || action == 'take') {
148
- if (!scrivito.editing_context.is_editing_mode()) {
149
- return scrivito.withSavingOverlay(
150
- scrivito.change_editing_context({display_mode: 'editing', workspace_id: 'rtc'}));
151
- } else {
152
- return scrivito.withSavingOverlay(scrivito.reload());
153
- }
154
- } else {
155
- return scrivito.withSavingOverlay(scrivito.reload());
156
- }
157
- }));
148
+ scrivito.withSavingOverlay(scrivito.ajax('PUT', 'objs/workflow/'+action, {data: {id: objId, comment: comment}}).then(reloadFunction));
158
149
  });
159
150
  };
160
151
 
@@ -164,8 +155,9 @@
164
155
  var buttons = page_config['buttons'] || [];
165
156
  var workflow_enabled = page_config['workflow'];
166
157
 
158
+ var source_frame = cms_document.browser_window();
167
159
 
168
- if (cms_document.browser_window().name !== 'scrivito_application') {
160
+ if (source_frame.name !== 'scrivito_application') {
169
161
  // TODO: add special handling for scrivito_details_dialog and scrivito_inspector
170
162
  var button;
171
163
 
@@ -183,7 +175,7 @@
183
175
  button.removeAttr('disabled');
184
176
  button.removeClass('disabled');
185
177
  button.click(function () {
186
- workflowAction(action, obj.id());
178
+ workflowAction(action, obj.id(), reloadGivenWindow(source_frame));
187
179
  });
188
180
 
189
181
  });
@@ -206,7 +198,7 @@
206
198
  button.removeAttr('disabled');
207
199
  button.removeClass('disabled');
208
200
  button.click(function () {
209
- releaseAction(obj.id());
201
+ releaseAction(obj.id(), reloadGivenWindow(source_frame));
210
202
  });
211
203
  }
212
204
  }
@@ -220,13 +212,10 @@
220
212
  icon: icons['release'],
221
213
 
222
214
  present: function() {
223
- return scrivito.editing_context.selected_workspace.is_editable() && obj && (!workflow_enabled || (buttons.indexOf('release') !== -1));
215
+ return scrivito.editingContext.selectedWorkspace.is_editable() && obj && (!workflow_enabled || (buttons.indexOf('release') !== -1));
224
216
  },
225
217
 
226
218
  disabled: function() {
227
- if (!obj.modification()) {
228
- return scrivito.t('commands.release_obj.not_modified_obj');
229
- }
230
219
  if (obj.has_restriction()) {
231
220
  return obj.restriction_messages().join("; ");
232
221
  }
@@ -237,7 +226,7 @@
237
226
  },
238
227
 
239
228
  execute: function() {
240
- return releaseAction(obj.id());
229
+ return releaseAction(obj.id(), pageActionComplete('release'));
241
230
  }
242
231
  });
243
232
  /* TODO: enforce permissions */
@@ -247,9 +236,17 @@
247
236
  /* disable editing */
248
237
  setTimeout(function (){
249
238
  if (page_config['editing_disabled']) {
250
- scrivito.editing_mode.disable(scrivito.t('editing_disabled.workflow'));
239
+ scrivito.editingMode.disable(scrivito.t('editing_disabled.workflow'));
251
240
  } else {
252
- scrivito.editing_mode.enable();
241
+ if (!scrivito.editingMode.isEnabled()) {
242
+ if (scrivito.editingContext.selectedWorkspace.is_editable()) {
243
+ scrivito.editingMode.enable(function (){
244
+ scrivito.changeEditingContext({display_mode: 'editing', workspace_id: 'rtc'});
245
+ });
246
+ } else {
247
+ scrivito.editingMode.enable();
248
+ }
249
+ }
253
250
  }
254
251
  }, 0);
255
252
 
@@ -264,7 +261,7 @@
264
261
  },
265
262
 
266
263
  execute: function() {
267
- return workflowAction(action, obj.id());
264
+ return workflowAction(action, obj.id(), pageActionComplete(action));
268
265
  }
269
266
  });
270
267
  });
@@ -1,10 +1,12 @@
1
- (function() {
1
+ "use strict";
2
+
3
+ (function () {
2
4
  _.extend(scrivito, {
3
- path_for_id: function(id) {
4
- return '/__scrivito/' + id;
5
+ path_for_id: function path_for_id(id) {
6
+ return "/__scrivito/" + id;
5
7
  },
6
8
 
7
- id_from_path: function(url) {
9
+ id_from_path: function id_from_path(url) {
8
10
  // -- PATCH BEGINS HERE --
9
11
  var match = /__scrivito\/([a-z0-9]{4,})/.exec(url);
10
12
  // -- PATHC ENDS HERE --
@@ -12,6 +14,10 @@
12
14
  if (match) {
13
15
  return match[1];
14
16
  }
17
+ },
18
+
19
+ detailsPathForId: function detailsPathForId(objId) {
20
+ return "/__scrivito/page_details/" + objId;
15
21
  }
16
22
  });
17
- })();
23
+ })();
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ (function () {
4
+ scrivito.BinaryRequest = {
5
+ // COMPLETELY NEW IMPLEMENTATION HERE
6
+ upload: function upload(objId, blob, filename, contentType) {
7
+ scrivito.write_monitor.start_write();
8
+ return uploadToBackend(objId, blob, filename, contentType)['finally'](scrivito.write_monitor.end_write);
9
+ },
10
+
11
+ copy: function copy(copyId, objId, filename, contentType) {
12
+ var encodedCopyId = encodeURIComponent(copyId);
13
+ var params = {};
14
+
15
+ if (filename) {
16
+ params.filename = filename;
17
+ }
18
+
19
+ if (contentType) {
20
+ params.content_type = contentType;
21
+ }
22
+
23
+ params.destination_obj_id = objId;
24
+
25
+ return scrivito.CmsRestApi.put('blobs/' + encodedCopyId + '/copy', params);
26
+ },
27
+
28
+ // For test purpose only.
29
+ getFormData: function getFormData() {
30
+ return new FormData();
31
+ }
32
+ };
33
+
34
+ function uploadToBackend(objId, blob, filename, contentType) {
35
+ var formData = scrivito.BinaryRequest.getFormData();
36
+ formData.append('obj_id', objId);
37
+ formData.append('filename', filename);
38
+ formData.append('content_type', contentType);
39
+ formData.append('file', blob);
40
+
41
+ return scrivito.Promise.resolve($.ajax({
42
+ method: 'POST',
43
+ url: '/_f7/uploads/temp',
44
+ data: formData,
45
+ // These are needed in order for jQuery to work properly with a FormData.
46
+ contentType: false,
47
+ processData: false,
48
+ xhrFields: { withCredentials: true }
49
+ })).then(function (blob_data) {
50
+ return blob_data;
51
+ });
52
+ };
53
+ })();
@@ -0,0 +1,122 @@
1
+ 'use strict';
2
+
3
+ (function () {
4
+ _.extend(scrivito, {
5
+ ajax: function ajax(type, path) {
6
+ var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
7
+
8
+ var isWriteRequest = type === 'PUT' || type === 'POST' || type === 'DELETE';
9
+ var skipWriteMonitor = options && options.skip_write_monitor;
10
+
11
+ if (isWriteRequest) {
12
+ options.timeout = 15000; // miliseconds
13
+
14
+ if (!skipWriteMonitor) {
15
+ scrivito.write_monitor.start_write();
16
+ }
17
+ }
18
+
19
+ var ajaxPromise = singleAjax(type, path, options).then(function (result) {
20
+ if (result && result.task && _.size(result) === 1) {
21
+ return handleTask(result.task);
22
+ }
23
+
24
+ return $.Deferred().resolve(result);
25
+ });
26
+
27
+ if (isWriteRequest && !skipWriteMonitor) {
28
+ ajaxPromise.always(function () {
29
+ scrivito.write_monitor.end_write();
30
+ });
31
+ }
32
+
33
+ return ajaxPromise;
34
+ },
35
+
36
+ ajaxWithErrorDialog: function ajaxWithErrorDialog(type, path, options) {
37
+ return scrivito.ajax(type, path, options).fail(function (error) {
38
+ scrivito.displayAjaxError(error);
39
+ });
40
+ },
41
+
42
+ displayAjaxError: function displayAjaxError(error) {
43
+ /*
44
+ let message;
45
+ let messageForEditor;
46
+ if (_.isObject(error)) {
47
+ message = scrivito.t('ajax_error', error.message);
48
+ messageForEditor = error.message_for_editor;
49
+ } else if (_.contains(['abort', 'parsererror', 'timeout'], error)) {
50
+ message = scrivito.t('ajax_error.communication');
51
+ } else {
52
+ message = scrivito.t('ajax_error', error);
53
+ }
54
+ if (scrivito.isDevelopmentMode) {
55
+ scrivito.alertDialog(message);
56
+ } else {
57
+ scrivito.logError(message);
58
+ scrivito.errorDialog(messageForEditor || scrivito.t('ajax_error.message_for_editor'),
59
+ [error.timestamp, message]);
60
+ }
61
+ */
62
+ // -- PATCH BEGINS HERE --
63
+ var message, message_for_editor;
64
+
65
+ if (_.isObject(error)) {
66
+ if (error.message) {
67
+ return scrivito.alertDialog(error.message);
68
+ } else {
69
+ return scrivito.alertDialog(scrivito.t('ajax_error.communication'));
70
+ }
71
+ } else if (_.contains(['abort', 'parsererror', 'timeout'], error)) {
72
+ message = scrivito.t('ajax_error.communication');
73
+ } else {
74
+ message = scrivito.t('ajax_error', error);
75
+ }
76
+ scrivito.logError(message);
77
+ scrivito.errorDialog(message_for_editor || scrivito.t('ajax_error.message_for_editor'), [error.timestamp, message]);
78
+ // -- PATCH ENDS HERE --
79
+ }
80
+ });
81
+
82
+ function handleTask(task) {
83
+ switch (task.status) {
84
+ case 'success':
85
+ return $.Deferred().resolve(task.result);
86
+ case 'error':
87
+ return $.Deferred().reject({
88
+ message: task.message,
89
+ code: task.code
90
+ });
91
+ case 'open':
92
+ return scrivito.wait(2).then(function () {
93
+ return singleAjax('GET', 'tasks/' + task.id);
94
+ }).then(handleTask);
95
+ default:
96
+ throw { message: 'Invalid task (unknown status)', task: task };
97
+ }
98
+ }
99
+
100
+ function singleAjax(type, path, options) {
101
+ var baseUrl = window.location.protocol + '//' + window.location.host + '/__scrivito/';
102
+ if (options && options.data) {
103
+ options.data = JSON.stringify(options.data);
104
+ }
105
+ var ajaxRequest = $.ajax(baseUrl + path, _.extend({
106
+ type: type,
107
+ dataType: 'json',
108
+ contentType: 'application/json; charset=utf-8',
109
+ cache: false }, // Don't cache GET requests.
110
+ options || {}));
111
+
112
+ return ajaxRequest.then(function (result) {
113
+ return $.Deferred().resolve(result);
114
+ }, function (xhr, _textStatus, xhrError) {
115
+ try {
116
+ return $.Deferred().reject(JSON.parse(xhr.responseText));
117
+ } catch (SyntaxError) {
118
+ return $.Deferred().reject(xhrError);
119
+ }
120
+ });
121
+ }
122
+ })();