diff --git a/js/source/legacy/CXGN/List.js b/js/source/legacy/CXGN/List.js
index ba864e01e5..decb5000f1 100644
--- a/js/source/legacy/CXGN/List.js
+++ b/js/source/legacy/CXGN/List.js
@@ -54,6 +54,9 @@ CXGN.List = function () {
+// Keep track of the rendered lists page number and sort column between refreshes
+var render_lists_page = 0; // first page
+var render_lists_order = [[0, "asc"]]; // sort by list name, ascending
CXGN.List.prototype = {
@@ -336,7 +339,11 @@ CXGN.List.prototype = {
},
renderLists: function(div) {
+ var type = jQuery('#render_lists_type').val();
+ var autocreated = jQuery("#render_lists_autocreated").is(":checked");
var lists = this.availableLists();
+ var types = this.allListTypes();
+
var html = '';
html = html + '
Select 2 or more lists in the Group column to modify or combine them
';
+ list_group_select_action_html += '
';
}
jQuery("#list_group_select_action").html(list_group_select_action_html);
+ }
+ jQuery('body').on("click", "input[name='list_select_checkbox']", render_selected_lists_container);
+ render_selected_lists_container();
+
+ jQuery(".render_lists_filter").on("change", function() {
+ render_lists_page = 0;
+ var lo = new CXGN.List();
+ lo.renderLists('list_dialog');
});
},
@@ -1718,36 +1797,69 @@ function makePrivateSelectedListGroup(list_ids) {
}
}
-function combineSelectedListGroup(list_ids) {
+/**
+ * Combine the items from the selected lists and create a new list
+ * The items can be combined either using a union method or intersection method
+ * @param {Array[Integer]} list_ids Array of List IDs of Lists to combine
+ * @param {String} type Method of combining lists (either 'union' or 'intersection', union is default)
+ */
+function combineSelectedListGroup(list_ids, type = 'union') {
var arrayLength = list_ids.length;
var list_name = jQuery('#new_combined_list_name').val();
- if (confirm('Combine selected lists into a new list called '+list_name+'?')) {
- var arrayItems = [];
+ if ( !list_name || list_name === '' ) return alert("You must enter a new list name first");
+
+ if ( confirm('Combine selected lists into a new list called '+list_name+'?') ) {
var lo = new CXGN.List();
- var first_list_type = lo.getListType(list_ids[0]);
- var same_list_types = true;
- for (var i=0; i 1 && !confirm('Are you sure you want to combine these list types: ' + list_types.join(', ')) ) return;
+
+ // Combine list items
+ var arrayItems = [];
+
+ // INTERSECTION
+ if ( type === 'intersection' ) {
+ var allListItems = [];
+ for ( var i=0; i result.filter(value => array.includes(value)));
}
- var new_list_id = lo.newList(list_name);
- if (same_list_types == true) {
- lo.setListType(new_list_id, first_list_type);
- }
- for (var i=0; i