Skip to content

Commit c9c83a9

Browse files
authored
Merge pull request #1286 from DDMAL/tab-fix
fix: tab & navigation status
2 parents 70b3a13 + fbc16e5 commit c9c83a9

File tree

3 files changed

+42
-25
lines changed

3 files changed

+42
-25
lines changed

rodan-client/code/src/js/Controllers/ControllerProject.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import ViewDeleteConfirm from '../Views/Master/Main/Shared/ViewDeleteConfirm';
1212
import ViewProject from 'js/Views/Master/Main/Project/Individual/ViewProject';
1313
import ViewProjectCollection from 'js/Views/Master/Main/Project/Collection/ViewProjectCollection';
1414
import ViewUserCollectionItem from 'js/Views/Master/Main/User/Collection/ViewUserCollectionItem';
15-
import ViewWorkflowRunCollection from 'js/Views/Master/Main/WorkflowRun/Collection/ViewWorkflowRunCollection';
16-
import WorkflowRunCollection from 'js/Collections/WorkflowRunCollection';
15+
import ViewResourceCollection from 'js/Views/Master/Main/Resource/Collection/ViewResourceCollection';
16+
import ResourceCollection from 'js/Collections/ResourceCollection';
1717

1818
/**
1919
* Controller for Projects.
@@ -245,18 +245,27 @@ export default class ControllerProject extends BaseController {
245245
*/
246246
_handleEventItemSelected(options) {
247247
this._activeProject = options.project;
248-
this._activeProject.fetch();
249-
250-
// default collection inside project view is the workflowrun collection
251-
var collection = new WorkflowRunCollection();
252-
collection.fetch({ data: { project: this._activeProject.id } });
253-
Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__UPDATER_SET_COLLECTIONS, { collections: [collection] });
254-
var viewProject = new ViewProject({ model: this._activeProject });
255-
Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__MAINREGION_SHOW_VIEW, {
256-
view: viewProject,
257-
options: { project: this._activeProject }
248+
249+
// Fetch project first and wait for it to complete
250+
this._activeProject.fetch({
251+
success: () => {
252+
// default collection inside project view is the resource collection
253+
var collection = new ResourceCollection();
254+
collection.fetch({ data: { project: this._activeProject.id } });
255+
256+
// Set up view
257+
Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__UPDATER_SET_COLLECTIONS, { collections: [collection] });
258+
var viewProject = new ViewProject({ model: this._activeProject });
259+
Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__MAINREGION_SHOW_VIEW, {
260+
view: viewProject,
261+
options: { project: this._activeProject }
262+
});
263+
264+
// Show resource collection by default and trigger resource selection event
265+
viewProject.showCollection(new ViewResourceCollection({ collection: collection }));
266+
Radio.channel('rodan').trigger(RODAN_EVENTS.EVENT__RESOURCE_SELECTED_COLLECTION, { project: this._activeProject });
267+
}
258268
});
259-
viewProject.showCollection(new ViewWorkflowRunCollection({ collection: collection }));
260269
}
261270

262271
/**

rodan-client/code/src/js/Views/Master/Main/Project/Individual/ViewProject.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import _ from 'underscore';
33
import RODAN_EVENTS from 'js/Shared/RODAN_EVENTS';
44
import Marionette from 'backbone.marionette';
55
import Radio from 'backbone.radio';
6+
import ViewResourceCollection from 'js/Views/Master/Main/Resource/Collection/ViewResourceCollection';
7+
import ViewWorkflowCollection from 'js/Views/Master/Main/Workflow/Collection/ViewWorkflowCollection';
8+
import ViewWorkflowRunCollection from 'js/Views/Master/Main/WorkflowRun/Collection/ViewWorkflowRunCollection';
9+
import ViewRunJobCollection from 'js/Views/Master/Main/RunJob/Collection/ViewRunJobCollection';
610

711
/**
812
* Project view.
@@ -27,6 +31,18 @@ export default class ViewProject extends Marionette.View {
2731
*/
2832
showCollection(view) {
2933
this.showChildView('regionCollection', view);
34+
35+
// Update tab status based on view type
36+
$('.project-nav-bar-btn').removeClass('active');
37+
if (view instanceof ViewResourceCollection) {
38+
$('#resource_count').addClass('active');
39+
} else if (view instanceof ViewWorkflowCollection) {
40+
$('#workflow_count').addClass('active');
41+
} else if (view instanceof ViewWorkflowRunCollection) {
42+
$('#button-workflow_runs').addClass('active');
43+
} else if (view instanceof ViewRunJobCollection) {
44+
$('#button-runjobs').addClass('active');
45+
}
3046
}
3147

3248
/**
@@ -82,35 +98,27 @@ export default class ViewProject extends Marionette.View {
8298
*/
8399
_handleButtonRunJobs() {
84100
Radio.channel('rodan').trigger(RODAN_EVENTS.EVENT__RUNJOB_SELECTED_COLLECTION, { project: this.model });
85-
$('.project-nav-bar-btn').removeClass('active');
86-
$('#button-runjobs').addClass('active');
87101
}
88102

89103
/**
90104
* Handle click resource count.
91105
*/
92106
_handleClickResourceCount() {
93107
Radio.channel('rodan').trigger(RODAN_EVENTS.EVENT__RESOURCE_SELECTED_COLLECTION, { project: this.model });
94-
$('.project-nav-bar-btn').removeClass('active');
95-
$('#resource_count').addClass('active');
96108
}
97109

98110
/**
99111
* Handle click workflow count.
100112
*/
101113
_handleClickWorkflowCount() {
102114
Radio.channel('rodan').trigger(RODAN_EVENTS.EVENT__WORKFLOW_SELECTED_COLLECTION, { view: this, project: this.model });
103-
$('.project-nav-bar-btn').removeClass('active');
104-
$('#workflow_count').addClass('active');
105115
}
106116

107117
/**
108118
* Handle button WorkflowRuns.
109119
*/
110120
_handleButtonWorkflowRuns() {
111121
Radio.channel('rodan').trigger(RODAN_EVENTS.EVENT__WORKFLOWRUN_SELECTED_COLLECTION, { project: this.model });
112-
$('.project-nav-bar-btn').removeClass('active');
113-
$('#button-workflow_runs').addClass('active');
114122
}
115123

116124
/**

rodan-client/code/templates/Views/Master/Main/Project/Individual/template-main_project_individual.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
<!-- Project collections (workflow runs, resources, etc.) -->
1010
<div class="content-wrapper column-content project-collections padding-10">
1111
<div class="content-wrapper row-content project-navigation-bar">
12-
<button class="btn project-nav-bar-btn active" id="button-workflow_runs">Workflow Runs</button>
13-
<button class="btn project-nav-bar-btn" id="button-runjobs">Run Jobs</button>
12+
<button class="btn project-nav-bar-btn" id="resource_count">Resources</button>
1413
<button class="btn project-nav-bar-btn" id="workflow_count">Workflows</button>
15-
<button class="btn project-nav-bar-btn" id="resource_count">Resources</button>
14+
<button class="btn project-nav-bar-btn" id="button-workflow_runs">Workflow Runs</button>
15+
<button class="btn project-nav-bar-btn" id="button-runjobs">Run Jobs</button>
1616
<!-- <button class="btn project-nav-bar-btn" id="button-resourcelists">Resource Lists: <%= resourcelist_count%></button> -->
1717
</div>
1818

@@ -36,7 +36,7 @@
3636
<div class="content-wrapper column-content details-panel-details-section padding-10">
3737
<div class="content-wrapper row-content details-item-container">
3838
<label class="details-item-label" for="text-project_name">Name:</label>
39-
<input class="details-item-value" type="text" class="form-control" id="text-project_name" value="<%= _.unescape(name) %>" name="text-project_name">
39+
<input class="details-item-value form-control" type="text" id="text-project_name" value="<%= _.unescape(name) %>" name="text-project_name">
4040
</div>
4141

4242
<div class="content-wrapper column-content details-item-container">

0 commit comments

Comments
 (0)