scrivito_content_browser 0.40.0 → 0.41.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 806c9ab13407327ead8d9aee15d1ba67fa1bd1e5
4
- data.tar.gz: 5f64eb899c7c6fbfdeb2d7419e2c25414cb9bc2d
3
+ metadata.gz: 7452d19d9b78a7bd3b272a23b2c2c989e03eee49
4
+ data.tar.gz: 7bf2b9950f63a2af06184671a81bbc0d89846ab2
5
5
  SHA512:
6
- metadata.gz: aedebe19185a7faf9a3914ea2647a2739216953a21d3f5fb70b2b8841ed84999ba699b6a4019815fe619ea169a0afbd50bdc5661ac37ec3b7567d5f50de29981
7
- data.tar.gz: 5726ffe674b422a8e2af44b288b27f0703a92dcc731c95fdd16de7081051bfebbbbff396b892810f49eaebeb117d0915395554d129466f441da9e4baee9babc5
6
+ metadata.gz: 6f5f6e66085b4c2c662276be0c745e8e77346373e75be7fa1d8640cc1b2938e122ea4c94d0c958ab8324df8d3b58273aed6e78521bc8f609b90ab6dd57f339f4
7
+ data.tar.gz: 9ade6519c8cf712c250537037e52409d46fd1ab5df5184f96096f46ca265c931388051f3d52616b18bfc4ef7ecaad38290c408c40d966af68d29fb42165e0698
@@ -22,56 +22,78 @@
22
22
  components: {},
23
23
  models: {},
24
24
  base_query: null,
25
- _center: function(domElement) {
26
- if (domElement) {
25
+ _center: function() {
26
+ var domElement, domElements, _i, _len, _results;
27
+ domElements = $(".scrivito-content-browser");
28
+ _results = [];
29
+ for (_i = 0, _len = domElements.length; _i < _len; _i++) {
30
+ domElement = domElements[_i];
27
31
  domElement = $(domElement);
28
- return domElement.css({
32
+ _results.push(domElement.css({
29
33
  marginLeft: -domElement.innerWidth() / 2,
30
34
  marginTop: -domElement.innerHeight() / 2,
31
35
  left: '50%'
32
- });
36
+ }));
33
37
  }
38
+ return _results;
34
39
  },
35
40
  _loadModal: function() {
36
- this.overlay = $('<div></div>').addClass('editing-overlay show').appendTo($('body'));
37
- this.modal = $('<div></div>').addClass('scrivito-content-browser show').attr('id', 'scrivito-content-browser').appendTo($('body'));
38
- this._center(this.modal);
39
- return $(window).resize((function(_this) {
40
- return function() {
41
- return _this._center(_this.modal);
42
- };
43
- })(this));
41
+ $('<div></div>').addClass('editing-overlay show').appendTo($('body'));
42
+ $('<div></div>').addClass('scrivito-content-browser show').appendTo($('body'));
43
+ return this._center();
44
44
  },
45
45
  _buildFilter: function(filter_definition) {
46
46
  return new models.Filter(filter_definition);
47
47
  },
48
- _startReact: function() {
48
+ _startReact: function(options, promise) {
49
49
  var baseQuery, filter, filterConfig;
50
- filterConfig = this.options.filters || this.filters;
51
- baseQuery = this.options.base_query || this.base_query;
50
+ filterConfig = options.filters || this.filters;
51
+ baseQuery = options.base_query || this.base_query;
52
52
  filter = this._buildFilter(filterConfig);
53
53
  return this._reactApp = React.render(React.createElement(ui.App, {
54
54
  "initialFilter": filter,
55
55
  "baseQuery": baseQuery,
56
- "container": this
57
- }), document.getElementById('scrivito-content-browser'));
56
+ "promise": promise,
57
+ "options": options
58
+ }), this._getLastContentBrowserElement());
59
+ },
60
+ _getLastElementByClassName: function(className) {
61
+ var elements;
62
+ elements = document.getElementsByClassName(className);
63
+ return _.last(elements);
64
+ },
65
+ _getLastOverlayElement: function() {
66
+ return this._getLastElementByClassName('editing-overlay show');
67
+ },
68
+ _getLastContentBrowserElement: function() {
69
+ return this._getLastElementByClassName('scrivito-content-browser show');
58
70
  },
59
71
  close: function() {
60
- this.overlay.remove();
61
- return this.modal.remove();
72
+ this._getLastOverlayElement().remove();
73
+ return this._getLastContentBrowserElement().remove();
62
74
  },
63
75
  open: function(options) {
76
+ var promise;
64
77
  if (options == null) {
65
78
  options = {};
66
79
  }
67
80
  if (!options.hasOwnProperty('base_preset')) {
68
81
  options.base_preset = this.base_preset;
69
82
  }
70
- this.options = options;
83
+ promise = $.Deferred();
71
84
  this._loadModal();
72
- this._startReact();
73
- this._promise = $.Deferred();
74
- return this._promise;
85
+ this._startReact(options, promise);
86
+ $(window).resize((function(_this) {
87
+ return function() {
88
+ return _this._center();
89
+ };
90
+ })(this));
91
+ promise.always((function(_this) {
92
+ return function() {
93
+ return _this.close();
94
+ };
95
+ })(this));
96
+ return promise;
75
97
  }
76
98
  };
77
99
  })();
@@ -132,7 +154,7 @@
132
154
 
133
155
  OptionFilterMixin = {
134
156
  mixins: [OptionFilterLabelRenderMixin],
135
- optionLabelToogleClick: function() {
157
+ optionLabelToggleClick: function() {
136
158
  return this.props.filter.toggleActive();
137
159
  },
138
160
  activeClassName: function() {
@@ -230,6 +252,137 @@
230
252
 
231
253
  })();
232
254
 
255
+ models.ActiveFilterNodeCollector = (function() {
256
+ function ActiveFilterNodeCollector(filter) {
257
+ this._filter = filter;
258
+ }
259
+
260
+ ActiveFilterNodeCollector.prototype.findActiveFilterItems = function() {
261
+ var filterItems, treeFilterItem;
262
+ filterItems = this._findActiveAdditionalFilters();
263
+ treeFilterItem = this._findActiveTreeFilterItem();
264
+ if (treeFilterItem) {
265
+ filterItems.unshift(treeFilterItem);
266
+ }
267
+ return filterItems;
268
+ };
269
+
270
+ ActiveFilterNodeCollector.prototype._findActiveTreeFilterItem = function() {
271
+ var activeConfig, subFilter, treeFilter, _i, _j, _len, _len1, _ref, _ref1;
272
+ _ref = this._filter.getTreeFilters();
273
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
274
+ treeFilter = _ref[_i];
275
+ _ref1 = treeFilter.subFilters;
276
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
277
+ subFilter = _ref1[_j];
278
+ activeConfig = this._findActiveSubFilterItem(subFilter);
279
+ if (activeConfig) {
280
+ activeConfig.parents.push(treeFilter.config);
281
+ return new models.ActiveNodeConfig(activeConfig.parents, [activeConfig.node]);
282
+ }
283
+ }
284
+ }
285
+ };
286
+
287
+ ActiveFilterNodeCollector.prototype._findActiveAdditionalFilters = function() {
288
+ var activeChildren, activeFilters, additionalFilter, _i, _len, _ref;
289
+ activeFilters = [];
290
+ _ref = this._filter.additionalFilters;
291
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
292
+ additionalFilter = _ref[_i];
293
+ activeChildren = _.filter(additionalFilter.children, function(child) {
294
+ return child.isActive();
295
+ });
296
+ if (activeChildren.length > 0) {
297
+ activeFilters.push(new models.ActiveNodeConfig([additionalFilter], activeChildren));
298
+ }
299
+ }
300
+ return activeFilters;
301
+ };
302
+
303
+ ActiveFilterNodeCollector.prototype._findActiveSubFilterItem = function(filterNode) {
304
+ var activeConfig, childNode, _i, _len, _ref;
305
+ if (filterNode.isActive()) {
306
+ return {
307
+ node: filterNode,
308
+ parents: []
309
+ };
310
+ } else {
311
+ _ref = filterNode.children;
312
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
313
+ childNode = _ref[_i];
314
+ activeConfig = this._findActiveSubFilterItem(childNode);
315
+ if (activeConfig) {
316
+ activeConfig.parents.push(filterNode);
317
+ return activeConfig;
318
+ }
319
+ }
320
+ }
321
+ };
322
+
323
+ return ActiveFilterNodeCollector;
324
+
325
+ })();
326
+
327
+ models.ActiveNodeConfig = (function() {
328
+ function ActiveNodeConfig(parents, nodes) {
329
+ this._parents = parents;
330
+ this._activeNodes = nodes;
331
+ }
332
+
333
+ ActiveNodeConfig.prototype.activeNodes = function() {
334
+ return this._activeNodes;
335
+ };
336
+
337
+ ActiveNodeConfig.prototype.values = function() {
338
+ return _.flatten(_.map(this._activeNodes, this._valueForNode));
339
+ };
340
+
341
+ ActiveNodeConfig.prototype.query = function() {
342
+ return this._filter().type !== 'checkbox' && this._activeNodes[0].query;
343
+ };
344
+
345
+ ActiveNodeConfig.prototype.hasQuery = function() {
346
+ return !!this.query();
347
+ };
348
+
349
+ ActiveNodeConfig.prototype.field = function() {
350
+ return this._findConfig('field');
351
+ };
352
+
353
+ ActiveNodeConfig.prototype.hasField = function() {
354
+ return !!this.field();
355
+ };
356
+
357
+ ActiveNodeConfig.prototype.operator = function() {
358
+ return this._findConfig('operator') || 'equals';
359
+ };
360
+
361
+ ActiveNodeConfig.prototype._valueForNode = function(node) {
362
+ return node.value || node.name;
363
+ };
364
+
365
+ ActiveNodeConfig.prototype._findConfig = function(attrName) {
366
+ var activeNode, parentWithAttribute;
367
+ activeNode = this._activeNodes[0];
368
+ if (this._filter().type !== 'checkbox' && activeNode[attrName]) {
369
+ return activeNode[attrName];
370
+ } else {
371
+ parentWithAttribute = _.find(this._parents, function(node) {
372
+ return node[attrName];
373
+ });
374
+ return parentWithAttribute && parentWithAttribute[attrName];
375
+ }
376
+ };
377
+
378
+ ActiveNodeConfig.prototype._filter = function() {
379
+ return _.last(this._parents);
380
+ };
381
+
382
+ return ActiveNodeConfig;
383
+
384
+ })();
385
+
233
386
  models.CheckboxFilter = (function(_super) {
234
387
  __extends(CheckboxFilter, _super);
235
388
 
@@ -263,7 +416,7 @@
263
416
 
264
417
  function CheckboxOption(filter, name, filterDefinition) {
265
418
  CheckboxOption.__super__.constructor.call(this, filter, name, filterDefinition);
266
- this.value = filterDefinition.value;
419
+ this.value = filterDefinition.value, this.preset = filterDefinition.preset;
267
420
  this.active = filterDefinition.selected;
268
421
  }
269
422
 
@@ -635,9 +788,95 @@
635
788
 
636
789
  })();
637
790
 
791
+ models.PresetBuilder = (function() {
792
+ var Preset;
793
+
794
+ Preset = (function() {
795
+ function Preset() {
796
+ this._errors = {};
797
+ this._values = {};
798
+ this._titles = {};
799
+ }
800
+
801
+ Preset.prototype.isValid = function() {
802
+ return _.keys(this.errors()).length === 0;
803
+ };
804
+
805
+ Preset.prototype.values = function() {
806
+ if (this.isValid()) {
807
+ return this._values;
808
+ } else {
809
+ throw new Error('#values can not be called on an invalid Preset');
810
+ }
811
+ };
812
+
813
+ Preset.prototype.errors = function() {
814
+ return this._errors;
815
+ };
816
+
817
+ Preset.prototype._addValue = function(key, value, title) {
818
+ if (this._values.hasOwnProperty(key)) {
819
+ return this._addError(key, this._titles[key], title);
820
+ } else {
821
+ this._values[key] = value;
822
+ return this._titles[key] = title;
823
+ }
824
+ };
825
+
826
+ Preset.prototype._addError = function(key, previouslySetValue, newValue) {
827
+ if (this._errors[key]) {
828
+ return this._errors[key].push(newValue);
829
+ } else {
830
+ return this._errors[key] = [previouslySetValue, newValue];
831
+ }
832
+ };
833
+
834
+ return Preset;
835
+
836
+ })();
837
+
838
+ function PresetBuilder(filter) {
839
+ this._collector = new models.ActiveFilterNodeCollector(filter);
840
+ }
841
+
842
+ PresetBuilder.prototype.generatePreset = function() {
843
+ var activeNodeConfigs, presetCollection;
844
+ presetCollection = new Preset();
845
+ activeNodeConfigs = this._collector.findActiveFilterItems();
846
+ _.each(activeNodeConfigs, (function(_this) {
847
+ return function(activeNodeConfig) {
848
+ var nodesWithPreset;
849
+ nodesWithPreset = _this._nodesWithPreset(activeNodeConfig);
850
+ return _.each(nodesWithPreset, function(filterNode) {
851
+ return _this._addPresetsForFilterNode(filterNode, presetCollection);
852
+ });
853
+ };
854
+ })(this));
855
+ return presetCollection;
856
+ };
857
+
858
+ PresetBuilder.prototype._nodesWithPreset = function(config) {
859
+ return _.select(config.activeNodes(), function(node) {
860
+ return node.preset;
861
+ });
862
+ };
863
+
864
+ PresetBuilder.prototype._addPresetsForFilterNode = function(node, presetCollection) {
865
+ return _.each(node.preset, function(value, key) {
866
+ if (value !== void 0) {
867
+ return presetCollection._addValue(key, value, node.title);
868
+ }
869
+ });
870
+ };
871
+
872
+ return PresetBuilder;
873
+
874
+ })();
875
+
638
876
  models.QueryBuilder = (function() {
639
877
  function QueryBuilder(filter, baseQuery) {
640
878
  this.filter = filter;
879
+ this._collector = new models.ActiveFilterNodeCollector(this.filter);
641
880
  if (baseQuery) {
642
881
  this._baseQuery = models.QueryBuilder.prepareQuery(baseQuery);
643
882
  }
@@ -646,56 +885,25 @@
646
885
  QueryBuilder.prototype.searchRequest = function() {
647
886
  var query;
648
887
  query = this._baseQuery;
649
- query = this._addTreeFilterQuery(query);
650
- query = this._addSearchTerm(query);
651
- return this._addAdditionalFilters(query);
888
+ query = this._addFilterQueries(query);
889
+ return query = this._addSearchTermQuery(query);
652
890
  };
653
891
 
654
- QueryBuilder.prototype._addAdditionalFilters = function(query) {
655
- var activeChildren, combinedQuery, filter, searchQuery, _i, _len, _ref;
656
- combinedQuery = query;
657
- _ref = this.filter.additionalFilters;
892
+ QueryBuilder.prototype._addFilterQueries = function(baseQuery) {
893
+ var activeConfig, combinedQuery, searchQuery, _i, _len, _ref;
894
+ combinedQuery = baseQuery;
895
+ _ref = this._collector.findActiveFilterItems();
658
896
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
659
- filter = _ref[_i];
660
- activeChildren = _.filter(filter.children, function(child) {
661
- return child.isActive();
662
- });
663
- if (activeChildren.length > 0) {
664
- searchQuery = this._buildActiveChildrenSearchQuery(activeChildren, filter);
665
- if (searchQuery != null) {
666
- combinedQuery = this._addOrCreateQuery(combinedQuery, searchQuery);
667
- }
897
+ activeConfig = _ref[_i];
898
+ searchQuery = this._buildActiveChildrenSearchQuery(activeConfig);
899
+ if (searchQuery) {
900
+ combinedQuery = this._addOrCreateQuery(combinedQuery, searchQuery);
668
901
  }
669
902
  }
670
903
  return combinedQuery;
671
904
  };
672
905
 
673
- QueryBuilder.prototype._buildActiveChildrenSearchQuery = function(activeChildren, filter) {
674
- if (filter.type === 'checkbox') {
675
- return this._buildFOVQuery(filter, activeChildren);
676
- } else {
677
- return this._buildRadioQuery(filter, activeChildren[0]);
678
- }
679
- };
680
-
681
- QueryBuilder.prototype._buildRadioQuery = function(filter, activeChild) {
682
- if (activeChild.query) {
683
- return activeChild.query;
684
- } else {
685
- return this._buildFOVQuery(filter, [activeChild]);
686
- }
687
- };
688
-
689
- QueryBuilder.prototype._buildFOVQuery = function(config, activeNodes) {
690
- var operator, values;
691
- values = _.flatten(_.map(activeNodes, function(node) {
692
- return node.value || node.name;
693
- }));
694
- operator = config.operator || 'equals';
695
- return scrivito.obj_where(config.field, operator, values);
696
- };
697
-
698
- QueryBuilder.prototype._addSearchTerm = function(query) {
906
+ QueryBuilder.prototype._addSearchTermQuery = function(query) {
699
907
  var searchQuery;
700
908
  if (this.filter.searchTerm && this.filter.searchTerm.length > 0) {
701
909
  searchQuery = scrivito.obj_where('*', 'contains_prefix', this.filter.searchTerm);
@@ -705,69 +913,17 @@
705
913
  }
706
914
  };
707
915
 
708
- QueryBuilder.prototype._createQueryByActiveConfig = function(activeConfig) {
709
- var field, operator;
710
- if (activeConfig.node.query) {
711
- return activeConfig.node.query;
916
+ QueryBuilder.prototype._buildActiveChildrenSearchQuery = function(activeConfig) {
917
+ if (activeConfig.hasQuery()) {
918
+ return activeConfig.query();
712
919
  } else {
713
- field = this._findField(activeConfig);
714
- if (field) {
715
- operator = this._findOperator(activeConfig);
716
- return this._buildFOVQuery({
717
- field: field,
718
- operator: operator
719
- }, [activeConfig.node]);
720
- }
920
+ return this._buildFOVQuery(activeConfig);
721
921
  }
722
922
  };
723
923
 
724
- QueryBuilder.prototype._addTreeFilterQuery = function(baseQuery) {
725
- var activeConfig, configuredQuery;
726
- activeConfig = this._findActiveTreeFilterItem();
727
- if (activeConfig) {
728
- configuredQuery = this._createQueryByActiveConfig(activeConfig);
729
- if (configuredQuery) {
730
- return this._addOrCreateQuery(baseQuery, configuredQuery);
731
- }
732
- } else {
733
- return baseQuery;
734
- }
735
- };
736
-
737
- QueryBuilder.prototype._findActiveTreeFilterItem = function() {
738
- var activeConfig, subFilter, treeFilter, _i, _j, _len, _len1, _ref, _ref1;
739
- _ref = this.filter.getTreeFilters();
740
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
741
- treeFilter = _ref[_i];
742
- _ref1 = treeFilter.subFilters;
743
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
744
- subFilter = _ref1[_j];
745
- activeConfig = this._findActiveSubFilterItem(subFilter);
746
- if (activeConfig) {
747
- activeConfig.parents.push(treeFilter.config);
748
- return activeConfig;
749
- }
750
- }
751
- }
752
- };
753
-
754
- QueryBuilder.prototype._findActiveSubFilterItem = function(filterNode) {
755
- var activeConfig, childNode, _i, _len, _ref;
756
- if (filterNode.isActive()) {
757
- return {
758
- node: filterNode,
759
- parents: []
760
- };
761
- } else {
762
- _ref = filterNode.children;
763
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
764
- childNode = _ref[_i];
765
- activeConfig = this._findActiveSubFilterItem(childNode);
766
- if (activeConfig) {
767
- activeConfig.parents.push(filterNode);
768
- return activeConfig;
769
- }
770
- }
924
+ QueryBuilder.prototype._buildFOVQuery = function(activeConfig) {
925
+ if (activeConfig.hasField()) {
926
+ return scrivito.obj_where(activeConfig.field(), activeConfig.operator(), activeConfig.values());
771
927
  }
772
928
  };
773
929
 
@@ -779,26 +935,6 @@
779
935
  }
780
936
  };
781
937
 
782
- QueryBuilder.prototype._findOperator = function(config) {
783
- return this._findAttributeInConfig('operator', config);
784
- };
785
-
786
- QueryBuilder.prototype._findField = function(config) {
787
- return this._findAttributeInConfig('field', config);
788
- };
789
-
790
- QueryBuilder.prototype._findAttributeInConfig = function(attributeName, config) {
791
- var parentWithAttribute;
792
- if (config.node[attributeName]) {
793
- return config.node[attributeName];
794
- } else {
795
- parentWithAttribute = _.find(config.parents, function(node) {
796
- return node[attributeName];
797
- });
798
- return parentWithAttribute && parentWithAttribute[attributeName];
799
- }
800
- };
801
-
802
938
  return QueryBuilder;
803
939
 
804
940
  })();
@@ -847,7 +983,7 @@
847
983
  function RadioOption(group, name, filterDefinition) {
848
984
  this.group = group;
849
985
  RadioOption.__super__.constructor.call(this, this.group.filter, name, filterDefinition);
850
- this.value = filterDefinition.value, this.query = filterDefinition.query;
986
+ this.value = filterDefinition.value, this.query = filterDefinition.query, this.preset = filterDefinition.preset;
851
987
  this.active = filterDefinition.selected;
852
988
  }
853
989
 
@@ -870,7 +1006,7 @@
870
1006
  var childrenDefinition;
871
1007
  TreeFilter.__super__.constructor.call(this, filter, name, filterDefinition);
872
1008
  this.type = 'tree';
873
- this.icon = filterDefinition.icon, this.query = filterDefinition.query, this.expanded = filterDefinition.expanded, this.value = filterDefinition.value, this.field = filterDefinition.field, this.operator = filterDefinition.operator;
1009
+ this.icon = filterDefinition.icon, this.query = filterDefinition.query, this.expanded = filterDefinition.expanded, this.value = filterDefinition.value, this.field = filterDefinition.field, this.operator = filterDefinition.operator, this.preset = filterDefinition.preset;
874
1010
  this.active = filterDefinition.selected;
875
1011
  childrenDefinition = filterDefinition.options || [];
876
1012
  this.children = _.map(childrenDefinition, function(definition, name) {
@@ -890,7 +1026,7 @@
890
1026
  return !!this.active;
891
1027
  };
892
1028
 
893
- TreeFilter.prototype.toogleActive = function() {
1029
+ TreeFilter.prototype.toggleActive = function() {
894
1030
  if (this.isActive()) {
895
1031
  this.active = false;
896
1032
  } else {
@@ -920,12 +1056,12 @@
920
1056
  models.UploadSet = (function(_super) {
921
1057
  __extends(UploadSet, _super);
922
1058
 
923
- function UploadSet(preset) {
924
- if (preset == null) {
925
- preset = {};
1059
+ function UploadSet(basePreset) {
1060
+ if (basePreset == null) {
1061
+ basePreset = {};
926
1062
  }
927
1063
  UploadSet.__super__.constructor.call(this);
928
- this._preset = preset;
1064
+ this._basePreset = basePreset;
929
1065
  this._uploads = [];
930
1066
  }
931
1067
 
@@ -933,10 +1069,14 @@
933
1069
  return this._uploads;
934
1070
  };
935
1071
 
936
- UploadSet.prototype.addFiles = function(files) {
1072
+ UploadSet.prototype.addFiles = function(files, presets) {
1073
+ if (presets == null) {
1074
+ presets = {};
1075
+ }
1076
+ presets = _.extend(_.clone(this._basePreset), presets);
937
1077
  _.each(files, (function(_this) {
938
1078
  return function(file) {
939
- return _this._uploads.unshift(new models.ObjUpload(_this, file, _this._preset));
1079
+ return _this._uploads.unshift(new models.ObjUpload(_this, file, presets));
940
1080
  };
941
1081
  })(this));
942
1082
  return this.changed();
@@ -1028,9 +1168,9 @@
1028
1168
  },
1029
1169
  getInitialState: function() {
1030
1170
  var basePreset, initialSelection, selectionMode;
1031
- initialSelection = this.props.container.options.selection || [];
1032
- selectionMode = this.props.container.options.selection_mode;
1033
- basePreset = this.props.container.options.base_preset;
1171
+ initialSelection = this.props.options.selection || [];
1172
+ selectionMode = this.props.options.selection_mode;
1173
+ basePreset = this.props.options.base_preset;
1034
1174
  return {
1035
1175
  filter: this.props.initialFilter,
1036
1176
  objs: [],
@@ -1059,11 +1199,12 @@
1059
1199
  "objCollection": this.state.objCollection,
1060
1200
  "viewMode": this.state.viewMode,
1061
1201
  "uploadSet": this.state.uploadSet,
1062
- "inspector": this.state.inspector
1202
+ "inspector": this.state.inspector,
1203
+ "filter": this.state.filter
1063
1204
  })), React.createElement(ui.Inspector, {
1064
1205
  "inspector": this.state.inspector
1065
1206
  })), React.createElement(ui.Footer, {
1066
- "container": this.props.container,
1207
+ "promise": this.props.promise,
1067
1208
  "objCollection": this.state.objCollection
1068
1209
  }));
1069
1210
  }
@@ -1202,7 +1343,7 @@
1202
1343
  render: function() {
1203
1344
  return React.createElement("li", {
1204
1345
  "className": this.activeClassName(),
1205
- "onClick": this.optionLabelToogleClick
1346
+ "onClick": this.optionLabelToggleClick
1206
1347
  }, React.createElement("div", {
1207
1348
  "className": "scrivito-content-browser-hierarchy-checkbox"
1208
1349
  }), this.renderOptionFilterTitle());
@@ -1248,7 +1389,7 @@
1248
1389
  ui.Filter.RadioOptionFilter = React.createClass({
1249
1390
  displayName: 'RadioOptionFilter',
1250
1391
  mixins: [OptionFilterMixin],
1251
- labelToogleClick: function() {
1392
+ labelToggleClick: function() {
1252
1393
  if (!this.props.filter.isActive()) {
1253
1394
  return this.props.filter.setActive();
1254
1395
  }
@@ -1256,7 +1397,7 @@
1256
1397
  render: function() {
1257
1398
  return React.createElement("li", {
1258
1399
  "className": this.activeClassName(),
1259
- "onClick": this.labelToogleClick
1400
+ "onClick": this.labelToggleClick
1260
1401
  }, React.createElement("div", {
1261
1402
  "className": "scrivito-content-browser-hierarchy-radio"
1262
1403
  }), this.renderOptionFilterTitle());
@@ -1326,8 +1467,8 @@
1326
1467
  }
1327
1468
  return _results;
1328
1469
  },
1329
- labelToogleClick: function() {
1330
- return this.props.filter.toogleActive();
1470
+ labelToggleClick: function() {
1471
+ return this.props.filter.toggleActive();
1331
1472
  },
1332
1473
  render: function() {
1333
1474
  var labelClasses;
@@ -1336,7 +1477,7 @@
1336
1477
  "className": labelClasses
1337
1478
  }, (!this.props.filter.isLeaf() ? this.renderArrowTag() : void 0), React.createElement("div", {
1338
1479
  "className": "scrivito-content-browser-hierarchy-label",
1339
- "onClick": this.labelToogleClick
1480
+ "onClick": this.labelToggleClick
1340
1481
  }, this.renderIconTag(), React.createElement("span", null, this.props.filter.title)), (!this.props.filter.isLeaf() ? React.createElement("ul", null, this.renderSubTrees()) : void 0));
1341
1482
  }
1342
1483
  });
@@ -1347,12 +1488,10 @@
1347
1488
  return this.props.objCollection.selectedObjs().length;
1348
1489
  },
1349
1490
  cancelClick: function() {
1350
- this.props.container._promise.reject();
1351
- return this.props.container.close();
1491
+ return this.props.promise.reject();
1352
1492
  },
1353
1493
  doneClick: function() {
1354
- this.props.container._promise.resolve(this.props.objCollection.selectedObjs());
1355
- return this.props.container.close();
1494
+ return this.props.promise.resolve(this.props.objCollection.selectedObjs());
1356
1495
  },
1357
1496
  deleteClick: function() {
1358
1497
  return this.props.objCollection.destroySelectedObjs();
@@ -1422,7 +1561,7 @@
1422
1561
  });
1423
1562
  },
1424
1563
  uploadFiles: function(event) {
1425
- var dataTransfer, files;
1564
+ var dataTransfer, files, message, preset;
1426
1565
  this.changeDragState(false)(event);
1427
1566
  dataTransfer = event.dataTransfer;
1428
1567
  if (dataTransfer == null) {
@@ -1430,9 +1569,23 @@
1430
1569
  }
1431
1570
  files = dataTransfer.files;
1432
1571
  if (files.length > 0) {
1433
- return this.props.uploadSet.addFiles(files);
1572
+ preset = this.buildPreset();
1573
+ if (preset.isValid()) {
1574
+ return this.props.uploadSet.addFiles(files, preset.values());
1575
+ } else {
1576
+ message = 'The selected filter options cannot be applied to the file(s) you wanted to upload. Please select only one of the following options, then try again:\n';
1577
+ _.each(preset.errors(), function(values, field) {
1578
+ return message += "\n" + field + ": " + (values.join(', '));
1579
+ });
1580
+ return alert(message);
1581
+ }
1434
1582
  }
1435
1583
  },
1584
+ buildPreset: function() {
1585
+ var presetBuilder;
1586
+ presetBuilder = new models.PresetBuilder(this.props.filter);
1587
+ return presetBuilder.generatePreset();
1588
+ },
1436
1589
  changeDragState: function(toValue) {
1437
1590
  return (function(_this) {
1438
1591
  return function(event) {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_content_browser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.40.0
4
+ version: 0.41.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-26 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-rails
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.40.0
47
+ version: 0.41.0.rc1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.40.0
54
+ version: 0.41.0.rc1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement