Commit 1b518446f153426b85a6b961f240631c9c067f59
1 parent
1b84784d
Exists in
master
and in
38 other branches
Create article
Showing
2 changed files
with
25 additions
and
3 deletions
Show diff stats
src/app/cms/cms.controller.js
... | ... | @@ -7,13 +7,25 @@ |
7 | 7 | |
8 | 8 | |
9 | 9 | /** @ngInject */ |
10 | - function CmsController(noosfero, $log, $stateParams, $scope) { | |
10 | + function CmsController(noosfero, $stateParams, $httpParamSerializer, $state) { | |
11 | 11 | var vm = this; |
12 | - vm.article = null; | |
12 | + vm.article = {}; | |
13 | 13 | vm.profile = null; |
14 | 14 | activate(); |
15 | 15 | |
16 | 16 | function activate() { |
17 | + vm.profile = noosfero.currentProfile; | |
18 | + } | |
19 | + | |
20 | + vm.save = function() { | |
21 | + noosfero.profiles.one(vm.profile.id).customPOST( | |
22 | + {article: vm.article}, | |
23 | + 'articles', | |
24 | + {}, | |
25 | + {'Content-Type':'application/json'} | |
26 | + ).then(function(response) { | |
27 | + $state.transitionTo('main.profile.page', {page: response.data.article.path, profile: vm.profile.identifier}); | |
28 | + }); | |
17 | 29 | } |
18 | 30 | |
19 | 31 | } | ... | ... |
src/app/cms/cms.html
1 | -CMS | |
1 | +<form> | |
2 | + <div class="form-group"> | |
3 | + <label for="titleInput">Title</label> | |
4 | + <input type="text" class="form-control" id="titleInput" placeholder="title" ng-model="vm.article.name"> | |
5 | + </div> | |
6 | + <div class="form-group"> | |
7 | + <label for="bodyInput">Text</label> | |
8 | + <textarea class="form-control" id="bodyInput" rows="10" ng-model="vm.article.body"></textarea> | |
9 | + </div> | |
10 | + <button type="submit" class="btn btn-default" ng-click="vm.save()">Save</button> | |
11 | +</form> | ... | ... |