nitweb: frontend load full mdoc
authorAlexandre Terrasa <alexandre@moz-code.org>
Sat, 17 Jun 2017 20:10:15 +0000 (16:10 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 15 Aug 2017 18:15:45 +0000 (14:15 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitweb/javascripts/entities.js
share/nitweb/views/doc/doc.html

index d5dd3ef..2958f58 100644 (file)
                                .state('doc.entity.doc', {
                                        url: '',
                                        templateUrl: 'views/doc/doc.html',
-                                       controller: function(mentity) {
+                                       resolve: {
+                                               doc: function(Model, $q, $stateParams, $state) {
+                                                       var d = $q.defer();
+                                                       Model.loadEntityDoc($stateParams.id, d.resolve,
+                                                               function() {
+                                                                       $state.go('404', null, { location: false })
+                                                               });
+                                                       return d.promise;
+                                               }
+                                       },
+                                       controller: function(mentity, doc) {
                                                this.mentity = mentity;
+                                               this.doc = doc;
                                        },
                                        controllerAs: 'vm',
                                })
                                                .error(cbErr);
                                },
 
+                               loadEntityDoc: function(id, cb, cbErr) {
+                                       $http.get('/api/entity/' + id + '/doc')
+                                               .success(cb)
+                                               .error(cbErr);
+                               },
+
                                loadEntityLinearization: function(id, cb, cbErr) {
                                        $http.get('/api/linearization/' + id)
                                                .success(cb)
index 1cf3c8b..e00f144 100644 (file)
@@ -3,7 +3,16 @@
                <ui-summary target='#summary-content' />
        </div>
        <div class='col-xs-9' id='summary-content'>
-               <entity-card mentity='vm.mentity' default-tab='doc' no-synopsis='true' />
+               <div class='card'>
+                       <div class='card-body'>
+                               <div ng-if='vm.doc'>
+                                       <div ng-bind-html='vm.doc.documentation'></div>
+                               </div>
+                               <div ng-if='!vm.doc'>
+                                       <i class='text-muted'>No documentation for this entity.</i>
+                               </div>
+                       </div>
+               </div>
 
                <entity-list list-title='Groups' list-entities='vm.mentity.mgroups'
                        list-object-filter='{}' />