66 white: true
77 */
88define ( [
9- 'jquery' ,
10- 'kb_dashboard_widget_base' ,
11- 'kb/widget/widgets/buttonBar' ,
12- 'bluebird' ,
13- 'bootstrap'
14- ] ,
15- function ( $ , DashboardWidget , Buttonbar , Promise ) {
9+ 'jquery' ,
10+ 'kb_dashboard_widget_base' ,
11+ 'kb/widget/widgets/buttonBar' ,
12+ 'bluebird' ,
13+ 'bootstrap'
14+ ] ,
15+ function ( $ , DashboardWidget , Buttonbar , Promise ) {
1616 "use strict" ;
1717 var widget = Object . create ( DashboardWidget , {
1818 init : {
19- value : function ( cfg ) {
19+ value : function ( cfg ) {
2020 cfg . name = 'PublicNarrativesWidget' ;
2121 cfg . title = 'Public Narratives' ;
2222 this . DashboardWidget_init ( cfg ) ;
@@ -28,17 +28,17 @@ define([
2828 }
2929 } ,
3030 getAppName : {
31- value : function ( name ) {
31+ value : function ( name ) {
3232 return this . getState ( [ 'appsMap' , name , 'name' ] , name ) ;
3333 }
3434 } ,
3535 getMethodName : {
36- value : function ( name ) {
36+ value : function ( name ) {
3737 return this . getState ( [ 'methodsMap' , name , 'name' ] , name ) ;
3838 }
3939 } ,
4040 renderLayout : {
41- value : function ( ) {
41+ value : function ( ) {
4242 this . container . html ( this . renderTemplate ( 'layout' ) ) ;
4343 this . places = {
4444 title : this . container . find ( '[data-placeholder="title"]' ) ,
@@ -49,56 +49,57 @@ define([
4949 }
5050 } ,
5151 setupUI : {
52- value : function ( ) {
52+ value : function ( ) {
5353 if ( this . hasState ( 'narratives' ) && this . getState ( 'narratives' ) . length > 0 ) {
5454 this . buttonbar = Object . create ( Buttonbar ) . init ( {
5555 container : this . container . find ( '[data-placeholder="buttonbar"]' )
5656 } ) ;
5757 this . buttonbar
5858 . clear ( )
5959
60- /*.addRadioToggle({
61- buttons: [
62- {
63- label: 'Slider',
64- active: true,
65- class: 'btn-kbase',
66- callback: function (e) {
67- this.view = 'slider';
68- this.refresh();
69- }.bind(this)
70- },
71- {
72- label: 'Table',
73- class: 'btn-kbase',
74- callback: function (e) {
75- this.view = 'table';
76- this.refresh();
77- }.bind(this)
78- }]
79- })
80- */
81- . addInput ( {
82- placeholder : 'Search' ,
83- place : 'end' ,
84- onkeyup : function ( e ) {
85- // little hack to make sure the public narratives is opened up.
86- var collapse = this . places . title , id ;
87- if ( collapse . hasClass ( 'collapsed' ) ) {
88- id = collapse . attr ( 'data-target' ) ;
89- $ ( id ) . collapse ( 'show' ) ;
90- }
60+ /*.addRadioToggle({
61+ buttons: [
62+ {
63+ label: 'Slider',
64+ active: true,
65+ class: 'btn-kbase',
66+ callback: function (e) {
67+ this.view = 'slider';
68+ this.refresh();
69+ }.bind(this)
70+ },
71+ {
72+ label: 'Table',
73+ class: 'btn-kbase',
74+ callback: function (e) {
75+ this.view = 'table';
76+ this.refresh();
77+ }.bind(this)
78+ }]
79+ })
80+ */
81+ . addInput ( {
82+ placeholder : 'Search' ,
83+ place : 'end' ,
84+ onkeyup : function ( e ) {
85+ // little hack to make sure the public narratives is opened up.
86+ var collapse = this . places . title ,
87+ id ;
88+ if ( collapse . hasClass ( 'collapsed' ) ) {
89+ id = collapse . attr ( 'data-target' ) ;
90+ $ ( id ) . collapse ( 'show' ) ;
91+ }
9192
92- this . filterState ( {
93- search : $ ( e . target ) . val ( )
94- } ) ;
95- } . bind ( this )
96- } ) ;
93+ this . filterState ( {
94+ search : $ ( e . target ) . val ( )
95+ } ) ;
96+ } . bind ( this )
97+ } ) ;
9798 }
9899 }
99100 } ,
100101 render : {
101- value : function ( ) {
102+ value : function ( ) {
102103 // Generate initial view based on the current state of this widget.
103104 // Head off at the pass -- if not logged in, can't show profile.
104105 if ( this . error ) {
@@ -120,24 +121,24 @@ define([
120121 }
121122 } ,
122123 filterState : {
123- value : function ( options ) {
124+ value : function ( options ) {
124125 if ( ! options . search || options . search . length === 0 ) {
125126 this . setState ( 'narrativesFiltered' , this . getState ( 'narratives' ) ) ;
126127 return ;
127128 }
128129 var searchRe = new RegExp ( options . search , 'i' ) ,
129- nar = this . getState ( 'narratives' ) . filter ( function ( x ) {
130+ nar = this . getState ( 'narratives' ) . filter ( function ( x ) {
130131 if (
131132 x . workspace . metadata . narrative_nice_name . match ( searchRe )
132133
133134 ||
134135
135- x . workspace . owner . match ( searchRe )
136+ x . workspace . owner . match ( searchRe )
136137
137138 ||
138139
139140 ( x . object . metadata . cellInfo &&
140- ( function ( apps ) {
141+ ( function ( apps ) {
141142 for ( var i in apps ) {
142143 var app = apps [ i ] ;
143144 if ( app . match ( searchRe ) || this . getAppName ( app ) . match ( searchRe ) ) {
@@ -149,7 +150,7 @@ define([
149150 ||
150151
151152 ( x . object . metadata . cellInfo &&
152- ( function ( methods ) {
153+ ( function ( methods ) {
153154 for ( var i in methods ) {
154155 var method = methods [ i ] ;
155156 if ( method . match ( searchRe ) || this . getMethodName ( method ) . match ( searchRe ) ) {
@@ -158,7 +159,7 @@ define([
158159 }
159160 } . bind ( this ) ) ( Object . keys ( x . object . metadata . cellInfo . method ) ) )
160161
161- ) {
162+ ) {
162163 return true ;
163164 } else {
164165 return false ;
@@ -168,11 +169,11 @@ define([
168169 }
169170 } ,
170171 onStateChange : {
171- value : function ( ) {
172- var count = this . doState ( 'narratives' , function ( x ) {
172+ value : function ( ) {
173+ var count = this . doState ( 'narratives' , function ( x ) {
173174 return x . length ;
174175 } , null ) ;
175- var filtered = this . doState ( 'narrativesFiltered' , function ( x ) {
176+ var filtered = this . doState ( 'narrativesFiltered' , function ( x ) {
176177 return x . length ;
177178 } , null ) ;
178179
@@ -190,12 +191,18 @@ define([
190191 }
191192 } ,
192193 setInitialState : {
193- value : function ( options ) {
194+ value : function ( options ) {
194195 return this . getNarratives ( {
195- showDeleted : 0 ,
196- excludeGlobal : 0
197- } )
198- . then ( function ( narratives ) {
196+ showDeleted : 0 ,
197+ excludeGlobal : 0
198+ } )
199+ . then ( function ( narratives ) {
200+ narratives = narratives . filter ( function ( x ) {
201+ if ( x . workspace . globalread === 'r' ) {
202+ return true ;
203+ }
204+ return false ;
205+ } . bind ( this ) ) ;
199206 this . setState ( 'narratives' , narratives ) ;
200207 this . setState ( 'narrativesFiltered' , narratives ) ;
201208 } . bind ( this ) ) ;
0 commit comments