nitweb/angular: add code to model
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 7 Jun 2016 16:45:13 +0000 (12:45 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 7 Jun 2016 16:45:13 +0000 (12:45 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitweb/javascripts/entities.js
share/nitweb/javascripts/model.js

index d1cad5f..4428c89 100644 (file)
                                        });
                        };
 
+                       this.loadEntityCode = function() {
+                               Model.loadEntityCode($routeParams.id,
+                                       function(data) {
+                                               $scope.code = data;
+                                       }, function(err) {
+                                               $scope.code = err;
+                                       });
+                       };
+
                        Model.loadEntity($routeParams.id,
                                function(data) {
                                        $scope.mentity = data;
index aae3cae..b3e2248 100644 (file)
                                                .error(cbErr);
                                },
 
+                               loadEntityCode: function(id, cb, cbErr) {
+                                       $http.get(apiUrl + '/code/' + id)
+                                               .success(cb)
+                                               .error(cbErr);
+                               },
+
                                search: function(q, n, cb, cbErr) {
                                        $http.get(apiUrl + '/search?q=' + q + '&n=' + n)
                                                .success(cb)