forked from ezsystems/PlatformUIBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ez-platformuiapp.js
931 lines (872 loc) · 33.9 KB
/
ez-platformuiapp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
/*
* Copyright (C) eZ Systems AS. All rights reserved.
* For full copyright and license information view LICENSE file distributed with this source code.
*/
YUI.add('ez-platformuiapp', function (Y) {
"use strict";
/**
* Provides the PlatformUI Application class
*
* @module ez-platformuiapp
*/
Y.namespace('eZ');
var L = Y.Lang,
APP_OPEN = 'is-app-open',
APP_LOADING = 'is-app-loading';
/**
* Fired whenever a fatal error occurs and application is not able to continue current action
*
* @event fatalError
* @param retryAction {Object} Object describing the action which was interrupted by error, and could be retried
* @param additionalInfo {Object} Object containing additional information about the error
* @example
* app.fire(EVT_FATALERROR, {
* retryAction: {
* run: app.loadContentForEdit,
* args: [req, res, next],
* context: app
* },
* additionalInfo: {
* errorText: " Could not load the content with id '" + req.params.id + "'"
* }
* });
*/
/**
* PlatformUI Application
*
* @namespace eZ
* @class PlatformUIApp
* @constructor
* @extends App
*/
Y.eZ.PlatformUIApp = Y.Base.create('platformuiApp', Y.App, [], {
/**
* The list of available sides views. Each side view is an entry in this
* hash which contains the following properties:
*
* * `type`: a reference to the constructor of a view
* * `container`: a selector to the node that will receive the
* rendered view
* * `hideClass`: a class to add on the application container to hide
* the rendered side view when it's not needed.
*
* The lifecycle of the side views is handled by the `handleSideViews`
* method based on the meta information available in the route.
*
* @property sideViews
* @type {Object}
*/
sideViews: {
discoveryBar: {
type: Y.eZ.DiscoveryBarView,
service: Y.eZ.DiscoveryBarViewService,
container: '.ez-menu-container',
hideClass: 'is-menu-hidden'
},
navigationHub: {
type: Y.eZ.NavigationHubView,
service: Y.eZ.NavigationHubViewService,
container: '.ez-navigation-container',
hideClass: 'is-navigation-hidden'
},
universalDiscovery: {
type: Y.eZ.UniversalDiscoveryView,
service: Y.eZ.UniversalDiscoveryViewService,
container: '.ez-universaldiscovery-container',
hideClass: 'is-universaldiscovery-hidden',
},
confirmBox: {
type: Y.eZ.ConfirmBoxView,
service: Y.eZ.ConfirmBoxViewService,
container: '.ez-confirmbox-container',
hideClass: 'is-confirmbox-hidden',
},
languageSelectionBox: {
type: Y.eZ.LanguageSelectionBoxView,
service: Y.eZ.LanguageSelectionBoxViewService,
container: '.ez-languageselectionbox-container',
hideClass: 'is-languageselectionbox-hidden',
},
notificationHub: {
type: Y.eZ.NotificationHubView,
service: Y.eZ.NotificationHubViewService,
container: '.ez-notification-container',
},
},
views: {
loginFormView: {
type: Y.eZ.LoginFormView,
},
dashboardView: {
type: Y.eZ.DashboardView,
parent: 'loginFormView',
},
studioPresentationView: {
type: Y.eZ.StudioPresentationView,
},
studioPlusPresentationView: {
type: Y.eZ.StudioPlusPresentationView,
},
contentEditView: {
type: Y.eZ.ContentEditView,
parent: 'locationViewView',
},
locationViewView: {
type: Y.eZ.LocationViewView,
parent: 'dashboardView'
},
serverSideView: {
type: Y.eZ.ServerSideView,
},
sectionServerSideView: {
type: Y.eZ.SectionServerSideView,
},
contentTypeEditServerSideView: {
type: Y.eZ.ContentTypeEditServerSideView,
},
},
/**
* Initializes the application.
*
* @method initializer
*/
initializer: function () {
/**
* Stores the initial title of the page so it can be used when
* generating the title depending on the active view
*
* @property _initialTitle
* @protected
* @default the actual page title
*/
this._initialTitle = Y.config.doc.title;
this.on({
'loadingChange': this._loading,
'navigate': function () {
this.set('loading', true);
}
});
this.after('activeViewServiceChange', function (event) {
var newService = event.newVal,
oldService = event.prevVal;
if (oldService && newService) {
oldService.setNextViewServiceParameters(newService);
}
});
this._routeConfig();
},
/**
* Reads the `routeConfig` configuration object and applies the given
* settings to the correct route.
*
* @protected
* @method _routeConfig
*/
_routeConfig: function () {
if (this.get('routeConfig')) {
Y.Array.each(this.get('routes'), Y.bind(this._enrichRoute, this));
}
},
/**
* Enrich the route with the route configuration
*
* @protected
* @method _enrichRoute
* @param {Object} route a route object (an entry in the `routes`
* attribute)
* @param {Number} index
*/
_enrichRoute: function (route, index) {
if (this.get('routeConfig')[route.name]) {
this.get('routes')[index].config = this.get('routeConfig')[route.name];
}
},
/**
* Generates the URI for a route identified by its name. All
* placeholders are replaced by the value found in the `params`
* parameters, if a value is not found in this object, the placeholder
* is replaced by an empty string.
*
* @method routeUri
* @param {String} routeName the name of the route to look for
* @param {Object} [params] an object containing the key/value to replace
* in the route path
* @return {String|Null} null if the route was not found
*/
routeUri: function (routeName, params) {
var route = Y.Array.find(this.get('routes'), function (elt) {
return (elt.name === routeName);
}),
prefix = this.get('root') + '#';
if ( !route ) {
return null;
}
return prefix + route.path.replace(/(:[a-z0-9]+)/gi, function (matched, placeholder) {
var paramName = placeholder.substr(1);
if ( !params[paramName] ) {
return '';
}
return Y.config.win.encodeURIComponent(params[paramName]);
});
},
/**
* Navigates to the given route build with the given parameters
*
* @method navigateTo
* @param {String} routeName
* @param {Object} [params]
*/
navigateTo: function (routeName, params) {
this.navigate(this.routeUri(routeName, params));
},
/**
* Logs in a user using the provided credentials. If the credentials
* are wrong, the callback is called with the error and response from
* CAPI.logIn. If the credentials are correct, the error and response
* arguments are set with the ones from eZ.UserModel.load method. If the
* user loading fails, the user is automatically logged out.
*
* @method logIn
* @param credentials {Object} object containing a `login` and a `password`
* entries
* @param callback {Function}
* @param callback.error {false|CAPIError}
* @param callback.response {Response}
*/
logIn: function (credentials, callback) {
var capi = this.get('capi'),
app = this;
capi.logIn(credentials, function (error, response) {
var user;
if ( error ) {
callback(error, response);
return;
}
user = app.get('user');
user.set('id', response.document.Session.User._href);
user.load({api: capi}, function (error, result) {
if ( error ) {
app.logOut(function () {
callback(error, result);
});
return;
}
callback(error, result);
});
});
},
/**
* Logs out the current user and resets it
*
* @method logOut
* @param {Function} callback
* @param {false|CAPIError} callback.error the error provided by the CAPI
* @param {Response} callback.response the response provided by the CAPI
*/
logOut: function (callback) {
var user = this.get('user');
this.get('capi').logOut(function (error, response) {
user.reset();
user.set('id', undefined);
callback(error, response);
});
},
/**
* Checks whether the user is logged in. From the application point of
* view, being logged in means the user has a session and this session
* is associated with a user which is not the anonymous user.
*
* @method isLoggedIn
* @param {Function} callback function called after the check
* @param {Boolean} callback.notLoggedIn false if the user is logged in,
* true otherwise
* @param {Object} [callback.response] the response object if a REST
* call is done
*/
isLoggedIn: function (callback) {
var capi = this.get('capi'),
anonymousUserId = this.get('anonymousUserId'),
userId = this.get('user').get('id');
if ( userId ) {
callback(userId === anonymousUserId);
return;
}
capi.isLoggedIn(function (error, response) {
if ( error || response.document.Session.User._href === anonymousUserId ) {
callback(true, response);
return;
}
callback(false, response);
});
},
/**
* Changes the application state to be open
*
* @method open
* @param {Object} req the request object
* @param {Function} res the response object
* @param {Function} next the function to pass control to the next route callback
*/
open: function (req, res, next) {
var container = this.get('container');
container.addClass(APP_OPEN);
if ( L.isFunction(next) ) {
next();
}
},
/**
* Middleware to handle the *side views* configured for the given route.
* Depending on the configuration, it will apply the CSS class to
* show/hide the side views. If a side view is not explicitely
* configured to be displayed, it is hidden.
*
* @method handleSideViews
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
handleSideViews: function (req, res, next) {
var routeSideViews = req.route.sideViews,
tasks = new Y.Parallel();
Y.Object.each(this.sideViews, function (viewInfo, key) {
if ( routeSideViews && routeSideViews[key] ) {
this._showSideView(viewInfo, req, res, undefined, tasks.add());
} else if ( routeSideViews && routeSideViews[key] !== undefined ) {
this._hideSideView(viewInfo);
}
}, this);
tasks.done(function () {
next();
});
},
/**
* Shows a side view based on its identifier in the sideViews hash.
* This method also allows to pass a configuration hash that will stored
* in the `config` attribute of the view service.
*
* @method showSideView
* @param {String} sideViewKey
* @param {Mixed} config
* @param {Function} next
*/
showSideView: function (sideViewKey, config, next) {
var activeViewService = this.get('activeViewService');
this._showSideView(
this.sideViews[sideViewKey],
activeViewService ? activeViewService.get('request') : null,
activeViewService ? activeViewService.get('response') : null,
config,
next
);
},
/**
* Hides a side view based on its identifier in the sideViews hash
*
* @method hideSideView
* @param {String} sideViewKey
*/
hideSideView: function (sideViewKey) {
this._hideSideView(this.sideViews[sideViewKey]);
},
/**
* Shows the side view
*
* @method _showSideView
* @param {Object} viewInfo the info hash of the side view to show
* @param {Object} req the request
* @param {Object} res the response
* @param {Function} next a callback function to call when the view is
* shown
* @protected
*/
_showSideView: function (viewInfo, req, res, config, next) {
var view, service,
container = this.get('container'),
app = this,
createView = !viewInfo.instance;
if ( !viewInfo.serviceInstance ) {
viewInfo.serviceInstance = new viewInfo.service({
app: this,
capi: this.get('capi'),
plugins: Y.eZ.PluginRegistry.getPlugins(viewInfo.service.NAME),
});
viewInfo.serviceInstance.on('error', function (e) {
app.fire('notify', {
notification: {
text: e.message,
identifier: "notification-" + e.target.name,
state: "error",
timeout: 0,
}
});
});
}
service = viewInfo.serviceInstance;
service.setAttrs({
config: config,
request: req,
response: res,
});
if ( createView ) {
viewInfo.instance = new viewInfo.type();
}
view = viewInfo.instance;
view.addTarget(service);
service.addTarget(this);
service.load(function () {
view.setAttrs(service.getViewParameters());
if ( createView ) {
view.render();
container.one(viewInfo.container).append(
view.get('container')
);
}
view.set('active', true);
container.removeClass(viewInfo.hideClass);
if ( next ) {
next();
}
});
},
/**
* Hides the side view
*
* @method _hideSideView
* @param {Object} viewInfo the info hash of the side view to hide
* @protected
*/
_hideSideView: function (viewInfo) {
var view;
this.get('container').addClass(viewInfo.hideClass);
if ( viewInfo.instance ) {
view = viewInfo.instance;
view.set('active', false);
viewInfo.serviceInstance.removeTarget(this);
}
},
/**
* Overrides the default implementation to set the view service as a
* bubble target of the view and the app as a bubble target of the view
* service.
*
* @protected
* @method _attachView
* @param {View} view
* @param {Boolean} preprend
*/
_attachView: function (view, prepend) {
var viewInfo = this.getViewInfo(view);
this.constructor.superclass._attachView.apply(this, arguments);
if ( viewInfo && viewInfo.service ) {
view.removeTarget(this);
view.addTarget(viewInfo.service);
viewInfo.service.addTarget(this);
}
},
/**
* Middleware to check whether the user is logged in. When not logged
* in, it redirects the user to the login form.
*
* @method checkUser
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
checkUser: function (req, res, next) {
var user = this.get('user'),
app = this,
capi = this.get('capi');
app.isLoggedIn(function (notLoggedIn, response) {
if ( notLoggedIn ) {
app.navigateTo('loginForm');
return;
}
if ( !user.get('id') ) {
user.set('id', response.document.Session.User._href);
user.load({api: capi}, function (error) {
if ( error ) {
app.logOut(function () {
app.navigateTo('loginForm');
});
return;
}
next();
});
} else {
next();
}
});
},
/**
* Middleware to display the main view which identifier is in the route
* metadata
*
* @method handleMainView
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
handleMainView: function (req, res, next) {
var app = this,
route = req.route,
ServiceContructor = route.service,
serviceInstance = route.serviceInstance,
viewInfo = this.getViewInfo(route.view),
showView = function (service) {
var parameters = service ? service.getViewParameters() : {};
app.showView(route.view, parameters, {
update: true,
render: true
});
};
if ( serviceInstance ) {
this.set('loading', true);
viewInfo.service = serviceInstance;
viewInfo.service.set('request', req);
viewInfo.service.set('response', res);
app._set('activeViewService', viewInfo.service);
viewInfo.service.load(showView);
} else if ( ServiceContructor ) {
this.set('loading', true);
route.serviceInstance = new ServiceContructor({
app: this,
capi: this.get('capi'),
request: req,
response: res,
plugins: Y.eZ.PluginRegistry.getPlugins(ServiceContructor.NAME),
config: route.config,
});
viewInfo.service = route.serviceInstance;
app._set('activeViewService', viewInfo.service);
viewInfo.service.on('error', function (e) {
app.fire('notify', {
notification: {
text: e.message,
identifier: "ViewService-notification-error",
state: "error",
timeout: 0,
}
});
app.set('loading', false);
});
viewInfo.service.load(showView);
} else {
showView();
}
},
/**
* `loadingChange` event handler. Adds or removes the `is-app-loading`
* class on the application container.
*
* @method _loading
* @protected
* @param {Object} e the event facade object of the loadingChange event
*/
_loading: function (e) {
if ( e.newVal ) {
this.get('container').addClass(APP_LOADING);
} else {
this.get('container').removeClass(APP_LOADING);
}
},
/**
* Overrides the default implementation to make sure the view `active`
* attribute is set to true after the view is attached to the
* DOM. It also sets the loading flag to false and make sure the title
* of the page is correct after changing the active view.
*
* @method _afterActiveViewChange
* @protected
* @param {Object} e activeViewChange event facade
*/
_afterActiveViewChange: function (e) {
var cb, prevView = e.prevVal, that = this,
handleActive = function (view) {
if ( prevView ) {
prevView.set('active', false);
}
view.set('active', true);
},
removeContainerTransformStyle = function (view) {
// removing transform style so that position fixed works
// as intended see https://jira.ez.no/browse/EZP-21895
view.get('container').setStyle('transform', 'none');
};
if ( e.options.callback ) {
cb = e.options.callback;
e.options.callback = function (view) {
that._setTitle(view);
cb(e.newVal);
removeContainerTransformStyle(view);
handleActive(view);
};
} else {
e.options.callback = function (view) {
that._setTitle(view);
removeContainerTransformStyle(view);
handleActive(view);
};
}
Y.eZ.PlatformUIApp.superclass._afterActiveViewChange.call(this, e);
this.set('loading', false);
},
/**
* Sets the title of the page using the new active view `getTitle`
* method if it exists, otherwise, it just restores the initial page
* title.
*
* @method _setTitle
* @protected
* @param {View} the active view
*/
_setTitle: function (view) {
if ( typeof view.getTitle === 'function' ) {
Y.config.doc.title = view.getTitle() + ' - ' + this._initialTitle;
} else {
Y.config.doc.title = this._initialTitle;
}
},
}, {
ATTRS: {
/**
* Stores the available routes for the application.
*
* In addition to what is described in the {{#crossLink "App"}}YUI
* App documentation{{/crossLink}}, each route can have several
* metadata (all optional):
*
* * `service`: contains a reference to a constructor function that
* extends {{#crossLink "eZ.ViewService"}}eZ.ViewService{{/crossLink}}.
* The {{#crossLink "eZ.PlatformUIApp/handleMainView:method"}}`handleMainView`{{/crossLink}}
* middleware is responsible for using this function to build the
* view service which can be used to inject custom variables in the
* top level view triggered by the route. This view service is
* also made a bubble target of the view so that it can react to
* any custom event fired by the view.
* * `name`: name of the route which is useful to generate an URI
* with {{#crossLink
* "eZ.PlatformUIApp/routeUri:method"}}Y.eZ.PlatformUIApp.routeUri{{/crossLink}}
* * `view`: the identifier of the view in the `views` hash to
* display. This is handled by the `handleMainView` middleware.
* * `sideViews`: a hash which keys are the side view keys in the
* sideViews property. A truthy value means that the
* corresponding side view should be visible, false means that
* the side view should be explicitely hidden. If a side view is
* not mentionned it means it should remain as it is.
*
* If a route provides both a `regex` and a `path` properties, the
* `regex` is used in the route matching process, while the `path`
* can be used in the reverse routing process (generation of a
* link). If no `path` is provided, no reverse routing is possible.
*
* @attribute routes
*/
routes: {
value: [{
name: "loginForm",
path: "/login",
service: Y.eZ.LoginFormViewService,
sideViews: {'navigationHub': false, 'discoveryBar': false},
view: 'loginFormView',
callbacks: ['open', 'handleSideViews', 'handleMainView']
}, {
name: "dashboard",
path: "/dashboard",
sideViews: {'navigationHub': true, 'discoveryBar': false},
view: 'dashboardView',
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
}, {
name: "studioPresentation",
path: "/studio/presentation",
sideViews: {'navigationHub': true, 'discoveryBar': false},
view: 'studioPresentationView',
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
}, {
name: "studioPlusPresentation",
path: "/studioplus/presentation",
sideViews: {'navigationHub': true, 'discoveryBar': false},
view: 'studioPlusPresentationView',
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
}, {
name: "translateContent",
path: '/edit/:id/:languageCode/:baseLanguageCode',
service: Y.eZ.ContentEditViewService,
sideViews: {'navigationHub': false, 'discoveryBar': false},
view: 'contentEditView',
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
}, {
name: "editContent",
path: '/edit/:id/:languageCode',
service: Y.eZ.ContentEditViewService,
sideViews: {'navigationHub': false, 'discoveryBar': false},
view: 'contentEditView',
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
}, {
name: "createContent",
path: '/create',
service: Y.eZ.ContentCreateViewService,
sideViews: {'navigationHub': false, 'discoveryBar': false},
view: 'contentEditView',
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
}, {
name: "viewLocation",
path: '/view/:id/:languageCode',
service: Y.eZ.LocationViewViewService,
sideViews: {'discoveryBar': true, 'navigationHub': true},
view: 'locationViewView',
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
}, {
name: "adminSection",
regex: /\/admin\/(pjax%2Fsection%2F.*)/,
keys: ['uri'],
path: "/admin/:uri",
sideViews: {'navigationHub': true, 'discoveryBar': false},
service: Y.eZ.SectionServerSideViewService,
view: "sectionServerSideView",
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
}, {
name: "adminContentTypeEdit",
regex: /\/admin\/(contenttype%2Fupdate%2F.*)/,
keys: ['uri'],
path: "/admin/:uri",
sideViews: {'navigationHub': true, 'discoveryBar': false},
service: Y.eZ.ServerSideViewService,
view: "contentTypeEditServerSideView",
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
}, {
name: "adminContentType",
regex: /\/admin\/(contenttype.*)/,
keys: ['uri'],
path: "/admin/:uri",
sideViews: {'navigationHub': true, 'discoveryBar': false},
service: Y.eZ.ServerSideViewService,
view: "serverSideView",
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
}, {
name: "adminGenericRoute",
path: "/admin/:uri",
sideViews: {'navigationHub': true, 'discoveryBar': false},
service: Y.eZ.ServerSideViewService,
view: "serverSideView",
callbacks: ['open', 'checkUser', 'handleSideViews', 'handleMainView']
},]
},
serverRouting: {
value: false
},
linkSelector: {
// this is to avoid the Y.App to capture the click on the links
// otherwise the custom code can not prevent a click on any
// link.
value: "a.ez-pjax-no-element"
},
transitions: {
value: {
navigate: 'fade',
toChild: 'fade',
toParent: 'fade'
}
},
/**
* The base URI to build the URI of the ajax request
*
* @attribute baseUri
* @default "/"
* @type String
*/
baseUri: {
value: "/"
},
/**
* The root directory where to find the assets.
*
* @attribute assetRoot
* @default "/"
* @type String
*/
assetRoot: {
value: "/"
},
/**
* Loading state. Tells whether the application is waiting for
* something to be loaded
*
* @attribute loading
* @default false
* @type boolean
*/
loading: {
validator: L.isBoolean,
value: false
},
/**
* Routes configuration
*
* It's an object supposed to contain the configuration of a route,
* the key is the name of the route it should match
* For example if you want to match "loginForm" route:
*
* "loginForm": {
* "fieldsViews": {
* "ezthing": 'Something'
* }
* },
*
* @attribute routeConfig
* @default null
* @type Object
* @writeOnce
*/
routeConfig: {
writeOnce: "initOnly",
value: null
},
/**
* eZ Publish REST client
*
* @attribute capi
* @default null
* @type {eZ.CAPI}
* @writeOnce
* @required
*/
capi: {
writeOnce: "initOnly",
value: null
},
/**
* The logged in user
*
* @attribute user
* @type {eZ.User}
* @readOnly
*/
user: {
readOnly: true,
valueFn: function () {
return new Y.eZ.User();
},
},
/**
* Active view service instance
*
* @attribute activeViewService
* @type {eZ.ViewService}
* @readOnly
*/
activeViewService: {
readOnly: true
},
/**
* Stores the REST id of the configured anonymous user
*
* @attribute anonymousUserId
* @type {String}
* @required
*/
anonymousUserId: {
writeOnce: "initOnly",
},
}
});
});