Skip to content

Commit

Permalink
Jkmarx/clean up ui grid defaults (#1687)
Browse files Browse the repository at this point in the history
* Fix spacing

* Update partial to view for clarity.

* Fix typo.

* Swap cart and control panel.

* Display control panel tree.

* Remove temp selected file display.

* Add pair styling.

* Tweak css.

* Add file relationship service and depth.

* Fix counters for each group.

* Display selected nodes.

* Move input group into control directive.

* Fix mapping function.

* Fix currentTypes generation.

* Max pairs length.

* Remove console logs

* Trigger current position change when a new tool is selected.

* Fix scope bug due to factory.

* Add comments.

* Remove cloak.

* Add unit test.

* Move attribute generation to service.

* Put method calls into activate method per style guide.

* Style guide changes.

* Add a popover to the selection grid.

* Close popover when not clicking on row.

* Add popover with custom template.

* Modify template to only open one popover at a time.

* rename method for clarity.

* Use jqlite instead.

* Add template to ui-grid selection.

* Add checkbox selection.

* Grab current uuids from service and dynamically create obj.

* Move input groups to service.

* Add a left float, unstyle list class.

* Show current group.

* Rename variable for clarity.

* Add data object to track current group's nodes.

* Remove buttons for now.

* Refactor according to style guide.

* Change method and variable name for clarity.

* Move selection obj to node-service.

* Fix bug which requires deep copy.

* Fix bug with removing selected nodes.

* Add comments.

* fix button css

* Refactor and added comments.

* Update title.

* Add unit for ctrl.

* Add iffy

* Add directive unit test.

* Add line break for readability.

* Add another directive unit test and remove unused variable.

* Update unit test.

* Fix typo in view location.

* Fix unit test.

* Add comments.

* Fix unit tests.

* Add file relationship test.

* Fix bug due to merge.

* Update directive with static url method.

* Remove unneccessary files.

* Fix formatting.

* Reflect selection in control panel.

* Remove recursive directive and rename for clarity.

* Reorder and used service for control panel.

* Fix indexing.

* Add css.

* Add borders to templates.

* Fix orderby .

* Remove current input group.

* Add unit test.

* Consolidate components.

* Disable remove/removeAll if groups are empty.

* Reorder variable and comment.

* Remove hr to keep styling consistent.

* Delete obj properties when empty.

* Split pair portion.

* Seperate pair/list section.

* Update selectionObj reference.

* Adjust css.

* Fix deselect checkbox when clearing group.

* Add list structure to control panel.

* Fix bug with popover.

* Fix remove and deselect bug.

* Add comments.

* Turn off select all.

* Add comments and unit tests.

* Add comment.

* Remove unused igv and visualization module.

* Remove from refinery app.

* Update api endpoint.

* Remove default stylin for selected rows.

* Remove default selection.

* Remove console.log.

* Remove reference to the ui-grid node selections.

* Update unit test.

* Update name for clarity.
  • Loading branch information
jkmarx committed Apr 25, 2017
1 parent d206c7e commit c0073de
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 310 deletions.
2 changes: 1 addition & 1 deletion refinery/tool_manager/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def setUp(self):
self.factory = APIRequestFactory()
self.view = ToolDefinitionsViewSet.as_view({'get': 'list'})

self.url_root = '/api/v2/tools/definitions/'
self.url_root = '/api/v2/tool_definitions/'

self.galaxy_instance = Instance.objects.create()
self.workflow_engine = WorkflowEngine.objects.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class="btn btn-primary btn-xs"
rp-analysis-launch-modal
ng-click="open()"
ng-disabled="isLaunchNodesSelectionEmpty() || !currentWorkflow.isAvailable()">
ng-disabled="!currentWorkflow.isAvailable()">
Run Analysis
</button>
</span>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

function toolsDefinitionsService ($resource, settings) {
var toolsDefinitions = $resource(
settings.appRoot + settings.refineryApiV2 + '/tools/definitions',
settings.appRoot + settings.refineryApiV2 + '/tool_definitions',
{},
{
query: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
.expectGET(
settings.appRoot +
settings.refineryApiV2 +
'/tools/definitions'
'/tool_definitions'
).respond(200, fakeResponse);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,6 @@ <h4>Inputs ({{currentWorkflow.getCategory()}})</h4>
</span>
</div>

<div ng-if="dataSet2Flag && currentWorkflow.isSingleInput()">
<rp-file-browser-node-group></rp-file-browser-node-group>
<div class="p-a-1">
<button
class="btn btn-warning"
rp-analysis-launch-modal
ng-click="open()"
ng-disabled="isLaunchNodesSelectionEmpty()">
Launch Analysis
</button>
</div>
</div>

<div ng-if="!dataSet2Flag">
<div ng-controller="NodeSetListApiCtrl" ng-if="currentWorkflow.isSingleInput()">
<ui-select
Expand Down
111 changes: 4 additions & 107 deletions refinery/ui/source/js/file-browser/ctrls/ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,9 @@
infiniteScrollUp: true,
infiniteScrollDown: true,
useExternalSorting: true,
enableRowSelection: true,
enableSelectAll: false,
selectionRowHeaderWidth: 35,
rowHeight: 35,
showGridFooter: true,
enableSelectionBatchEvent: true,
multiSelect: true,
columnDefs: fileBrowserFactory.customColumnNames,
data: fileBrowserFactory.assayFiles,
Expand All @@ -94,9 +91,6 @@
vm.refreshSelectedFieldFromQuery = refreshSelectedFieldFromQuery;
vm.reset = reset;
vm.rowCount = maxFileRequest;
vm.selectNodesCount = 0;
vm.setGridSelectedRows = setGridSelectedRows;
vm.setGridUnselectedRows = setGridUnselectedRows;
vm.sortChanged = sortChanged;
vm.totalPages = 1; // variable supporting ui-grid dynamic scrolling
/** Used by ui to select/deselect, attributes have an object of filter fields
Expand All @@ -111,18 +105,6 @@
* -----------------------------------------------------------------------------
*/
function activate () {
// custom icon for ui-grid selection
$templateCache.put('ui-grid/selectionRowHeaderButtons',
'<div>' +
'<a rp-node-selection-popover title="Select Tool Input"' +
'ng-class="{\'ui-grid-row-selected\': row.isSelected}" ' +
'class="ui-grid-selection-row-header-buttons" ' +
'ng-click="selectButtonClick(row, $event); ' +
'grid.appScope.openSelectionPopover(row.entity.uuid);"' +
'id="{{row.entity.uuid}}">' +
'<i class="fa fa-arrow-right ui-grid-checks"' +
' aria-hidden="true"></i></a></div>'
);
// Ensure data owner
checkDataSetOwnership();
// initialize the dataset and updates ui-grid selection, filters, and url
Expand Down Expand Up @@ -252,64 +234,16 @@
// Sort events
vm.gridApi.core.on.sortChanged(null, vm.sortChanged);
vm.sortChanged(vm.gridApi.grid, [vm.gridOptions.columnDefs[1]]);

// Checkbox selection events
vm.gridApi.selection.on.rowSelectionChanged(null, function (row) {
angular.copy(row.entity, nodesService.activeNodeRow);
// When selected All, watching the deselect events for complement nodes
if (nodesService.selectedNodeGroupUuid &&
nodesService.selectedNodeGroupUuid !==
nodesService.defaultCurrentSelectionUuid) {
if (vm.afterNodeGroupUpdate) {
vm.afterNodeGroupUpdate = false;
nodesService.resetNodeGroupSelection(true);
}
}

if (nodesService.selectedAllFlag) {
nodesService.setComplementSeletedNodes(row);
vm.selectNodesCount = vm.assayFilesTotal -
nodesService.complementSelectedNodes.length;
} else {
// add or remove row to list
nodesService.setSelectedNodes(row);
vm.selectNodesCount = nodesService.selectedNodes.length;
}

// when not current selection, check if a new row was deselect/selected
if (nodesService.selectedNodeGroupUuid !==
nodesService.defaultCurrentSelectionUuid &&
nodesService.selectedNodesUuidsFromNodeGroup.length !==
nodesService.selectedNodes.length) {
// Reset the node group selection to current selection
nodesService.resetNodeGroupSelection(true);
}
});

// Event only occurs when checkbox is selected/deselected.
vm.gridApi.selection.on.rowSelectionChangedBatch(null, function
(eventRows) {
// When event all occurs, the node group should be current selection
nodesService.resetNodeGroupSelection(true);
// Checking the first row selected, ensures it's a true select all
if (eventRows[0].isSelected) {
nodesService.setSelectedAllFlags(true);
// Need to manually set vm.selectNodesCount to count of all list
vm.selectNodesCount = vm.assayFilesTotal;
} else {
nodesService.setSelectedAllFlags(false);
vm.selectNodesCount = 0;
}
});
}
}

/** vm method to open the selection popover and disable all popovers, so
* only one shows at a time. Needed in the ctrl due to ui-grid template.
* @param nodeUuid
*/
function openSelectionPopover (nodeUuid) {
angular.element('#' + nodeUuid).popover('show');
function openSelectionPopover (nodeRow) {
angular.copy(nodeRow, nodesService.activeNodeRow);
angular.element('#' + nodeRow.uuid).popover('show');
angular.element('.ui-grid-selection-row-header-buttons').popover('disable');
}

Expand Down Expand Up @@ -383,48 +317,11 @@
// timeout needed allows digest cycle to complete,and grid to ingest the data
vm.gridApi.infiniteScroll.resetScroll(vm.firstPage > 0, vm.lastPage < vm.totalPages);
resetGridService.setResetGridFlag(false);
// Select rows either from node group lists or previously selected
if (nodesService.selectedNodesUuidsFromNodeGroup.length > 0) {
nodesService.setSelectedNodesFromNodeGroup(
nodesService.selectedNodesUuidsFromNodeGroup
);
nodesService.selectNodesCount = nodesService
.selectedNodesUuidsFromNodeGroup.length;
correctRowSelectionInUI();
vm.afterNodeGroupUpdate = true;
} else if (nodesService.selectedNodes.length > 0) {
nodesService.selectNodesCount = nodesService.selectedNodesUuids.length;
correctRowSelectionInUI();
} else {
vm.gridApi.selection.clearSelectedRows();
nodesService.selectNodesCount = 0;
}
});
});
}
}

// Helper function: select rows on the ui-grid
function setGridSelectedRows (uuidsList) {
// If user scrolls quickly, there could be a delay for selected items
angular.forEach(vm.gridApi.grid.rows, function (gridRow) {
if (uuidsList.indexOf(gridRow.entity.uuid) > -1) {
vm.gridApi.selection.selectRow(gridRow.entity);
}
});
}

// Helper function: unselect rows on the ui-grid
function setGridUnselectedRows (uuidsList) {
// If user scrolls quickly, there could be a delay for selected items
angular.forEach(vm.gridApi.grid.rows, function (gridRow) {
// select rows if not in complement list
if (uuidsList.indexOf(gridRow.entity.uuid) === -1) {
vm.gridApi.selection.selectRow(gridRow.entity);
}
});
}

/**
* Generates sort param for api call from ui-grid response and calls grid
* reset
Expand Down Expand Up @@ -481,6 +378,7 @@
});
};

// TODO: Update with the new selected rows and the indicator column.
// Method to select/deselect rows programmically after dynamic
// scroll adds more data, at reset and per 300 rows
var correctRowSelectionInUI = function () {
Expand Down Expand Up @@ -554,7 +452,6 @@
});
selectedFilterService.resetAttributeFilter(fieldsObj);
});
vm.selectNodesCount = 0;
vm.filesParam.filter_attribute = {};
vm.reset();
}
Expand Down
4 changes: 0 additions & 4 deletions refinery/ui/source/js/file-browser/ctrls/node-group-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ function NodeGroupCtrl (
resetGridService.setResetGridFlag(true);
};

// helper method checking if any nodes are selected
vm.isNodeGroupSelectionEmpty = function () {
return selectedNodesService.isNodeSelectionEmpty();
};
/*
* -----------------------------------------------------------------------------
* Watchers and Method Calls
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div id="assay-files-table"
ui-grid="FBCtrl.gridOptions"
ui-grid-selection
ui-grid-infinite-scroll
ui-grid-resize-columns
class="grid">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ <h2>
</span>
<div class="p-l-1-3 p-t-1-2 inline">
<button
ng-disabled="FBNGCtrl.isNodeGroupSelectionEmpty()"
class="btn btn-primary btn-xs p-r-1-3"
rp-file-browser-node-group-modal
refinery-tooltip
Expand Down
27 changes: 27 additions & 0 deletions refinery/ui/source/js/file-browser/services/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function fileBrowserFactory (
angular.copy(culledAttributes, assayAttributes);
// Add file_download column first
assayAttributes.unshift({ display_name: 'Url', internal_name: 'Url' });
assayAttributes.unshift({ display_name: 'Selection', internal_name: 'Selection' });
// some attributes will be duplicate in different fields, duplicate
// column names will throw an error. This prevents duplicates
for (var ind = 0; ind < assayAttributes.length; ind++) {
Expand Down Expand Up @@ -239,6 +240,30 @@ function fileBrowserFactory (
return internalName;
};

var setCustomSelectColumn = function (columnName) {
var cellTemplate = '<div class="ngCellText text-align-center">' +
'<a rp-node-selection-popover title="Select Tool Input"' +
'class="ui-grid-selection-row-header-buttons" ' +
'ng-click="selectButtonClick(row, $event); ' +
'grid.appScope.openSelectionPopover(row.entity);"' +
'id="{{row.entity.uuid}}">' +
'<i class="fa fa-arrow-right ui-grid-checks"' +
' aria-hidden="true"></i></a></div>';

return {
name: columnName,
field: columnName,
cellTooltip: true,
width: 4 + '%',
displayName: '',
enableFiltering: false,
enableSorting: false,
enableColumnMenu: false,
enableColumnResizing: true,
cellTemplate: cellTemplate
};
};

/**
* Helper method for file download column, requires unique template & fields.
* @param {string} _columnName - column name
Expand Down Expand Up @@ -300,6 +325,8 @@ function fileBrowserFactory (
if (columnName === 'Url') {
// Url requires a custom template for downloading links
tempCustomColumnNames.push(setCustomUrlColumnDef(columnName));
} else if (columnName === 'Selection') {
tempCustomColumnNames.push(setCustomSelectColumn(columnName));
} else if (columnName === 'Analysis Group') {
// Analysis requires a custom template for filtering -1 entries
var _cellTemplate = '<div class="ngCellText text-align-center"' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

function selectedNodesService ($window, selectedFilterService) {
var vm = this;
vm.selectedNodes = [];
vm.selectedNodesUuids = [];
vm.selectedNodesUuidsFromNodeGroup = [];
vm.selectedAllFlag = false;
vm.complementSelectedNodes = [];
vm.complementSelectedNodesUuids = [];
vm.selectedNodeGroupUuid = '';
vm.defaultCurrentSelectionUuid = '';
vm.resetNodeGroup = false;
Expand All @@ -29,29 +24,6 @@ function selectedNodesService ($window, selectedFilterService) {
});
};

/**
* Manually keep track of selected nodes which is neccessary due to dynamic
* scrolling in the ui-grid
* @param {obj} nodeRow - ui-grid row obj
* */
vm.setSelectedNodes = function (nodeRow) {
var ind = vm.selectedNodesUuids.indexOf(nodeRow.entity.uuid);
if (nodeRow.isSelected) {
if (ind === -1) {
vm.selectedNodes.push(nodeRow);
vm.selectedNodesUuids.push(nodeRow.entity.uuid);
}
// Have to set explictly to keep deleted rows from infinite scrolling
} else if (nodeRow.isSelected === false) {
if (ind > -1) {
vm.selectedNodesUuids.splice(ind, 1);
vm.selectedNodes.splice(ind, 1);
}
}
// else nothing because it is not in current block of data
return vm.selectedNodes;
};

/**
* Deep copy of a list of node uuids to the selected uuids from node group
* @param {list} nodesUuidsList - list of uuids
Expand Down Expand Up @@ -99,28 +71,6 @@ function selectedNodesService ($window, selectedFilterService) {
}
};

/**
* These are non-selected nodes uuid, when the select all flag is true
* @param {obj} nodeRow - ui-grid row object or ui-grid structured row objects
*/
vm.setComplementSeletedNodes = function (nodeRow) {
var ind = vm.complementSelectedNodesUuids.indexOf(nodeRow.entity.uuid);
if (nodeRow.isSelected === false) {
if (ind === -1) {
vm.complementSelectedNodes.push(nodeRow);
vm.complementSelectedNodesUuids.push(nodeRow.entity.uuid);
}
// Have to set explictly to keep deleted rows from infinite scrolling
} else if (nodeRow.isSelected === true) {
if (ind > -1) {
vm.complementSelectedNodes.splice(ind, 1);
vm.complementSelectedNodesUuids.splice(ind, 1);
}
}
// else nothing should occur to nodeRow because it is not in assayFiles
return vm.complementSelectedNodes;
};

/**
* Resets Node Group UI-Select menu to default Current Selection
* @param {boolean} flag - resets boolean
Expand Down Expand Up @@ -152,17 +102,6 @@ function selectedNodesService ($window, selectedFilterService) {
}
return params;
};


// Used by ctrls for node-group and launch-analysis partials to designate
// whether any nodes are selected.
vm.isNodeSelectionEmpty = function () {
var params = vm.getNodeGroupParams();
if (params.nodes.length === 0 && !params.use_complement_nodes) {
return true;
}
return false;
};
}

angular.module('refineryFileBrowser')
Expand Down

0 comments on commit c0073de

Please sign in to comment.