Created
September 5, 2016 14:34
-
-
Save hyperNURb/772560a3f222f40ac947a138e7fbc907 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/ggrc/assets/javascripts/components/csv/export.js b/src/ggrc/assets/javascripts/components/csv/export.js | |
| index 91faaa6..1a0c488 100644 | |
| --- a/src/ggrc/assets/javascripts/components/csv/export.js | |
| +++ b/src/ggrc/assets/javascripts/components/csv/export.js | |
| @@ -151,8 +151,10 @@ | |
| }); | |
| return { | |
| object_name: panel.type, | |
| - fields: _.compact(_.map(Object.keys(panel.selected), function (key) { | |
| - return panel.selected[key] === true ? key : null; | |
| + fields: _.compact(_.map(panel.columns(), function (item, index) { | |
| + if (panel.selected[index]) { | |
| + return item.key; | |
| + } | |
| })), | |
| filters: GGRC.query_parser.join_queries( | |
| GGRC.query_parser.parse(relevant_filter || ""), | |
| @@ -245,25 +247,27 @@ | |
| } | |
| this.setSelected(); | |
| }, | |
| - "[data-action=attribute_select_toggle] click": function (el, ev) { | |
| - var items = GGRC.model_attr_defs[this.scope.attr("item.type")], | |
| - split_items = { | |
| - mappings: _.filter(items, function (el) { | |
| - return el.type === "mapping"; | |
| - }), | |
| - attributes: _.filter(items, function (el) { | |
| - return el.type !== "mapping"; | |
| - }) | |
| - }; | |
| - _.map(split_items[el.data("type")], function (attr) { | |
| - this.scope.attr("item.selected." + attr.key, el.data("value")); | |
| + '[data-action=attribute_select_toggle] click': function (el, ev) { | |
| + var items = GGRC.model_attr_defs[this.scope.attr('item.type')]; | |
| + var isMapping = el.data('type') === 'mappings'; | |
| + var value = el.data('value'); | |
| + | |
| + _.each(items, function (item, index) { | |
| + if (isMapping && item.type === 'mapping') { | |
| + this.scope.attr('item.selected.' + index, value); | |
| + } | |
| + if (!isMapping && item.type !== 'mapping') { | |
| + this.scope.attr('item.selected.' + index, value); | |
| + } | |
| }.bind(this)); | |
| }, | |
| "setSelected": function () { | |
| - this.scope.attr("item.selected", _.reduce(this.scope.attr("item").columns(), function (memo, data) { | |
| - memo[data.key] = true; | |
| + var selected = _.reduce(this.scope.attr("item").columns(), function (memo, data, index) { | |
| + memo[index] = true; | |
| return memo; | |
| - }, {})); | |
| + }, {}); | |
| + | |
| + this.scope.attr("item.selected", selected); | |
| }, | |
| "{scope.item} type": function () { | |
| this.scope.attr("item.selected", {}); | |
| diff --git a/src/ggrc/assets/mustache/import_export/export/attribute_selector.mustache b/src/ggrc/assets/mustache/import_export/export/attribute_selector.mustache | |
| index d76476c..d6c91a0 100644 | |
| --- a/src/ggrc/assets/mustache/import_export/export/attribute_selector.mustache | |
| +++ b/src/ggrc/assets/mustache/import_export/export/attribute_selector.mustache | |
| @@ -17,14 +17,15 @@ | |
| <a data-action="attribute_select_toggle" data-value="false" data-type="mappings" href="javascript://">None</a> | |
| <div class="attribute-wrap"> | |
| <ul class="attr-list"> | |
| - {{#columns}} | |
| + {{#each columns}} | |
| <li> | |
| <label> | |
| - <input can-value="selected.{{key}}" type="checkbox" name="{{key}}" checked> | |
| + {{@index}} | |
| + <input can-value="selected.{{@index}}" type="checkbox" name="{{key}}" checked> | |
| {{display_name}} | |
| </label> | |
| </li> | |
| - {{/columns}} | |
| + {{/each}} | |
| </ul> | |
| </div> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment