Skip to content

Commit 22a4a23

Browse files
authored
Merge pull request #43 from eapearson/master
add workspace id to narrative filter conditions
2 parents cffa33c + 8036ca0 commit 22a4a23

File tree

9 files changed

+44
-43
lines changed

9 files changed

+44
-43
lines changed

dist.tgz

-168 Bytes
Binary file not shown.

src/plugin/iframe_root/modules/widgets/NarrativesWidget.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ define(['jquery', './DashboardWidget', 'kbaseUI/widget/buttonBar', 'bootstrap'],
7272
nar = this.getState('narratives').filter(
7373
function (x) {
7474
if (
75+
String(x.workspace.id) === search ||
7576
x.workspace.metadata.narrative_nice_name.match(searchRe) ||
7677
(x.object.metadata.cellInfo &&
7778
function (apps) {

src/plugin/iframe_root/modules/widgets/NarratorialsWidget.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ define(['jquery', './DashboardWidget', 'kbaseUI/widget/buttonBar', 'bootstrap'],
5151
},
5252
filterNarratives: {
5353
value: function () {
54-
var search = this.getParam('filter'),
55-
searchRe = new RegExp(search, 'i'),
56-
nar;
54+
const search = this.getParam('filter');
55+
const searchRe = new RegExp(search, 'i');
5756
if (!search || search.length === 0) {
5857
this.setState('narrativesFiltered', this.getState('narratives'));
5958
return;
6059
}
61-
nar = this.getState('narratives').filter(
60+
const nar = this.getState('narratives').filter(
6261
function (x) {
6362
if (
63+
String(x.workspace.id) === search ||
6464
x.workspace.metadata.narrative_nice_name.match(searchRe) ||
6565
(x.object.metadata.cellInfo &&
6666
function (apps) {
@@ -137,7 +137,7 @@ define(['jquery', './DashboardWidget', 'kbaseUI/widget/buttonBar', 'bootstrap'],
137137
}
138138
},
139139
setInitialState: {
140-
value: function (options) {
140+
value: function () {
141141
return this.getNarratives({
142142
type: 'narratorial'
143143
}).then(

src/plugin/iframe_root/modules/widgets/PublicNarrativesWidget.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ define(['jquery', './DashboardWidget', 'kbaseUI/widget/buttonBar', 'bootstrap'],
8787
this.setState('narrativesFiltered', this.getState('narratives'));
8888
return;
8989
}
90-
var searchRe = new RegExp(options.search, 'i'),
91-
nar = this.getState('narratives').filter(
92-
function (x) {
93-
if (
90+
const search = options.search;
91+
const searchRe = new RegExp(options.search, 'i');
92+
const nar = this.getState('narratives').filter(
93+
function (x) {
94+
if (
95+
String(x.workspace.id) === search ||
9496
x.workspace.metadata.narrative_nice_name.match(searchRe) ||
9597
x.workspace.owner.match(searchRe) ||
9698
(x.object.metadata.cellInfo &&
@@ -111,13 +113,13 @@ define(['jquery', './DashboardWidget', 'kbaseUI/widget/buttonBar', 'bootstrap'],
111113
}
112114
}
113115
}.bind(this)(Object.keys(x.object.metadata.cellInfo.method)))
114-
) {
115-
return true;
116-
} else {
117-
return false;
118-
}
119-
}.bind(this)
120-
);
116+
) {
117+
return true;
118+
} else {
119+
return false;
120+
}
121+
}.bind(this)
122+
);
121123
this.setState('narrativesFiltered', nar);
122124
}
123125
},

src/plugin/iframe_root/modules/widgets/SharedNarrativesWidget.js

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
define(['jquery', './DashboardWidget', 'kbaseUI/widget/buttonBar', 'bluebird', 'bootstrap'], function (
1+
define([
2+
'jquery',
3+
'./DashboardWidget',
4+
'kbaseUI/widget/buttonBar',
5+
6+
'bootstrap'
7+
], function (
28
$,
39
DashboardWidget,
4-
Buttonbar,
5-
Promise
10+
Buttonbar
611
) {
712
'use strict';
813
var widget = Object.create(DashboardWidget, {
@@ -82,6 +87,7 @@ define(['jquery', './DashboardWidget', 'kbaseUI/widget/buttonBar', 'bluebird', '
8287
var nar = this.getState('narratives').filter(
8388
function (x) {
8489
if (
90+
String(x.workspace.id) === search ||
8591
x.workspace.metadata.narrative_nice_name.match(searchRe) ||
8692
x.workspace.owner.match(searchRe) ||
8793
(x.object.metadata.cellInfo &&
@@ -135,25 +141,8 @@ define(['jquery', './DashboardWidget', 'kbaseUI/widget/buttonBar', 'bluebird', '
135141
});
136142
}
137143
},
138-
getAppsx: {
139-
value: function () {
140-
var methodStore = new NarrativeMethodStore(
141-
this.runtime.getConfig('services.narrative_method_store.url'),
142-
{
143-
token: this.runtime.service('session').getAuthToken()
144-
}
145-
);
146-
return Promise.all([methodStore.list_apps({})]).spread(function (apps) {
147-
var appMap = {};
148-
apps.forEach(function (app) {
149-
appMap[app.id] = app;
150-
});
151-
return appMap;
152-
});
153-
}
154-
},
155144
setInitialState: {
156-
value: function (options) {
145+
value: function () {
157146
return this.getNarratives({
158147
type: 'shared'
159148
}).then(

src/plugin/iframe_root/resources/NarrativesWidget/templates/slider.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
{% else %} {% for narrative in state.narrativesFiltered %}
2828
<div class="-card" id="narrative-{{narrative.object.wsid}}">
2929
<div class="-title">
30-
<a target="_blank" href="{{ env.getConfig(" services.narrative.url ") }}/narrative/{{narrative.object.wsid}}">{{narrative.workspace.metadata.narrative_nice_name}}</a>
30+
<a
31+
target="_blank"
32+
title="Narrative id {{narrative.object.wsid}}"
33+
href="{{ env.getConfig(" services.narrative.url ") }}/narrative/">{{narrative.workspace.metadata.narrative_nice_name}}</a>
3134
</div>
3235
<div class="-body">
3336
<div class="apps">

src/plugin/iframe_root/resources/NarratorialsWidget/templates/slider.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
{% else %} {% for narrative in state.narrativesFiltered %}
2121
<div class="-card" id="narrative-{{narrative.object.wsid}}">
2222
<div class="-title">
23-
<a target="_blank" href="{{ env.getConfig(" services.narrative.url ") }}/narrative/{{narrative.object.wsid}}">{{narrative.workspace.metadata.narrative_nice_name}}</a>
23+
<a
24+
target="_blank"
25+
title="Narrative id {{narrative.object.wsid}}"
26+
href="{{ env.getConfig(" services.narrative.url ") }}/narrative/{{narrative.object.wsid}}">{{narrative.workspace.metadata.narrative_nice_name}}</a>
2427
</div>
2528
<div class="-body">
2629
<div class="apps">

src/plugin/iframe_root/resources/PublicNarrativesWidget/templates/slider.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{% for narrative in state.narrativesFiltered %}
2121
<div class="-card" id="narrative-{{narrative.object.wsid}}">
2222
<div class="-title">
23-
<a target="_blank" href="{{ env.getConfig(" services.narrative.url ") }}/narrative/{{narrative.object.wsid}}">{{narrative.workspace.metadata.narrative_nice_name}}</a>
23+
<a target="_blank" title="Narrative id {{narrative.object.wsid}}" ref="{{ env.getConfig(" services.narrative.url ") }}/narrative/{{narrative.object.wsid}}">{{narrative.workspace.metadata.narrative_nice_name}}</a>
2424
</div>
2525
<div class="-body">
2626
<div class="apps">
@@ -159,8 +159,8 @@
159159
<span class="fa fa-minus dimmed" data-container="body" data-placement="auto" data-toggle="tooltip" style="opacity: 0.4;" title="Sharing information not available for this read-only Narrative"></span>
160160
{% else %}
161161
{# Note: narrative sharing permissions are not reported for the current user -- we must grok that from other
162-
properties. E.g. in this case we know the current user permission is 'w', which is only possible when then
163-
narrative has been shared thus. #}
162+
properties. E.g. in this case we know the current user permission is 'w', which is only possible when then
163+
narrative has been shared thus. #}
164164
{% if narrative.permissions|length == 0 %}
165165
<span data-container="body" data-placement="auto" data-toggle="tooltip" title="This narrative has been shared with you, but not anyone else.">
166166
1

src/plugin/iframe_root/resources/SharedNarrativesWidget/templates/slider.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
{% for narrative in state.narrativesFiltered %}
2121
<div class="-card" id="narrative-{{narrative.object.wsid}}">
2222
<div class="-title">
23-
<a target="_blank" href="{{ env.getConfig(" services.narrative.url ") }}/narrative/{{narrative.object.wsid}}">{{narrative.workspace.metadata.narrative_nice_name}}</a>
23+
<a
24+
target="_blank"
25+
title="Narrative id {{narrative.object.wsid}}"
26+
href="{{ env.getConfig(" services.narrative.url ") }}/narrative/{{narrative.object.wsid}}">{{narrative.workspace.metadata.narrative_nice_name}}</a>
2427
</div>
2528
<div class="-body">
2629
<div class="apps">

0 commit comments

Comments
 (0)