Commit 65a721944518e9df9373ca42617089e217970c56
1 parent
4dc814d9
Exists in
master
and in
35 other branches
Migrate profile controller
Showing
5 changed files
with
54 additions
and
54 deletions
Show diff stats
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +import {StateConfig, Component, Inject} from 'ng-forward'; | ||
2 | + | ||
3 | +@Component({ | ||
4 | + selector: 'cms', | ||
5 | + templateUrl: "app/cms/cms.html" | ||
6 | +}) | ||
7 | +@Inject("noosfero", "$stateParams", "$httpParamSerializer", "$state", "SweetAlert") | ||
8 | +export class Cms { | ||
9 | + | ||
10 | + article: any = {}; | ||
11 | + profile: any; | ||
12 | + | ||
13 | + constructor(private noosfero, private $stateParams, private $httpParamSerializer, private $state, private SweetAlert) { | ||
14 | + | ||
15 | + } | ||
16 | + | ||
17 | + save() { | ||
18 | + this.noosfero.currentProfile.then((profile) => { | ||
19 | + return this.noosfero.profiles.one(profile.id).customPOST( | ||
20 | + { article: this.article }, | ||
21 | + 'articles', | ||
22 | + {}, | ||
23 | + { 'Content-Type': 'application/json' } | ||
24 | + ) | ||
25 | + }).then((response) => { | ||
26 | + this.$state.transitionTo('main.profile.page', { page: response.data.article.path, profile: response.data.article.profile.identifier }); | ||
27 | + this.SweetAlert.swal({ | ||
28 | + title: "Good job!", | ||
29 | + text: "Article saved!", | ||
30 | + type: "success", | ||
31 | + timer: 1000 | ||
32 | + }); | ||
33 | + }); | ||
34 | + } | ||
35 | + | ||
36 | +} |
src/app/cms/cms.controller.js
@@ -1,35 +0,0 @@ | @@ -1,35 +0,0 @@ | ||
1 | -(function() { | ||
2 | - 'use strict'; | ||
3 | - | ||
4 | - angular | ||
5 | - .module('noosferoApp') | ||
6 | - .controller('CmsController', CmsController); | ||
7 | - | ||
8 | - | ||
9 | - /** @ngInject */ | ||
10 | - function CmsController(noosfero, $stateParams, $httpParamSerializer, $state, SweetAlert) { | ||
11 | - var vm = this; | ||
12 | - vm.article = {}; | ||
13 | - vm.profile = null; | ||
14 | - | ||
15 | - vm.save = function() { | ||
16 | - noosfero.currentProfile.then(function(profile) { | ||
17 | - return noosfero.profiles.one(profile.id).customPOST( | ||
18 | - {article: vm.article}, | ||
19 | - 'articles', | ||
20 | - {}, | ||
21 | - {'Content-Type':'application/json'} | ||
22 | - ) | ||
23 | - }).then(function(response) { | ||
24 | - $state.transitionTo('main.profile.page', {page: response.data.article.path, profile: response.data.article.profile.identifier}); | ||
25 | - SweetAlert.swal({ | ||
26 | - title: "Good job!", | ||
27 | - text: "Article saved!", | ||
28 | - type: "success", | ||
29 | - timer: 1000 | ||
30 | - }); | ||
31 | - }); | ||
32 | - } | ||
33 | - | ||
34 | - } | ||
35 | -})(); |
src/app/index.route.ts
@@ -3,16 +3,6 @@ | @@ -3,16 +3,6 @@ | ||
3 | /** @ngInject */ | 3 | /** @ngInject */ |
4 | export function routeConfig($stateProvider, $urlRouterProvider) { | 4 | export function routeConfig($stateProvider, $urlRouterProvider) { |
5 | $stateProvider | 5 | $stateProvider |
6 | - .state("main.profile.cms", { | ||
7 | - url: "^/myprofile/:profile/cms", | ||
8 | - views: { | ||
9 | - "mainBlockContent": { | ||
10 | - templateUrl: "app/cms/cms.html", | ||
11 | - controller: "CmsController", | ||
12 | - controllerAs: "vm" | ||
13 | - } | ||
14 | - } | ||
15 | - }) | ||
16 | .state("main.profile.settings", { | 6 | .state("main.profile.settings", { |
17 | url: "^/myprofile/:profile" | 7 | url: "^/myprofile/:profile" |
18 | }) | 8 | }) |
src/app/index.ts
@@ -8,13 +8,14 @@ import {routeConfig} from "./index.route"; | @@ -8,13 +8,14 @@ import {routeConfig} from "./index.route"; | ||
8 | import {ContentViewer as noosferoContentViewer} from "./content-viewer/content-viewer.component"; | 8 | import {ContentViewer as noosferoContentViewer} from "./content-viewer/content-viewer.component"; |
9 | import {Profile as noosferoProfile} from "./profile/profile.component"; | 9 | import {Profile as noosferoProfile} from "./profile/profile.component"; |
10 | import {ProfileInfo as noosferoProfileInfo} from "./profile-info/profile-info.component"; | 10 | import {ProfileInfo as noosferoProfileInfo} from "./profile-info/profile-info.component"; |
11 | +import {Cms as noosferoCms} from "./cms/cms.component"; | ||
11 | 12 | ||
12 | import {Main} from "./main/main.component"; | 13 | import {Main} from "./main/main.component"; |
13 | import {bootstrap, bundle} from "ng-forward"; | 14 | import {bootstrap, bundle} from "ng-forward"; |
14 | 15 | ||
15 | 16 | ||
16 | 17 | ||
17 | -declare var moment: any; | 18 | +declare var moment: any; |
18 | 19 | ||
19 | let noosferoApp: any = bundle("noosferoApp", Main, ["ngAnimate", "ngCookies", "ngStorage", "ngTouch", | 20 | let noosferoApp: any = bundle("noosferoApp", Main, ["ngAnimate", "ngCookies", "ngStorage", "ngTouch", |
20 | "ngSanitize", "ngMessages", "ngAria", "restangular", | 21 | "ngSanitize", "ngMessages", "ngAria", "restangular", |
@@ -34,16 +35,11 @@ NoosferoApp.addConstants("AUTH_EVENTS", { | @@ -34,16 +35,11 @@ NoosferoApp.addConstants("AUTH_EVENTS", { | ||
34 | NoosferoApp.addConfig(noosferoModuleConfig); | 35 | NoosferoApp.addConfig(noosferoModuleConfig); |
35 | NoosferoApp.run(noosferoAngularRunBlock); | 36 | NoosferoApp.run(noosferoAngularRunBlock); |
36 | 37 | ||
37 | -require("./cms/cms.controller.js"); | ||
38 | require("./components/auth/auth.controller.js"); | 38 | require("./components/auth/auth.controller.js"); |
39 | require("./components/auth/auth.service.js"); | 39 | require("./components/auth/auth.service.js"); |
40 | require("./components/navbar/navbar.directive.js"); | 40 | require("./components/navbar/navbar.directive.js"); |
41 | require("./components/noosfero-activities/activities.component.js"); | 41 | require("./components/noosfero-activities/activities.component.js"); |
42 | require("./components/noosfero-activities/activity/activity.component.js"); | 42 | require("./components/noosfero-activities/activity/activity.component.js"); |
43 | - | ||
44 | -// require("./components/noosfero-articles/blog/blog.component.js"); | ||
45 | - | ||
46 | - | ||
47 | require("./components/noosfero-blocks/block.directive.js"); | 43 | require("./components/noosfero-blocks/block.directive.js"); |
48 | require("./components/noosfero-blocks/link-list/link-list.component.js"); | 44 | require("./components/noosfero-blocks/link-list/link-list.component.js"); |
49 | require("./components/noosfero-blocks/main-block/main-block.component.js"); | 45 | require("./components/noosfero-blocks/main-block/main-block.component.js"); |
@@ -55,11 +51,11 @@ require("./components/noosfero/noosfero-template.filter.js"); | @@ -55,11 +51,11 @@ require("./components/noosfero/noosfero-template.filter.js"); | ||
55 | require("./components/noosfero/noosfero.service.js"); | 51 | require("./components/noosfero/noosfero.service.js"); |
56 | require("./components/noosfero/profile-image/profile-image.component.js"); | 52 | require("./components/noosfero/profile-image/profile-image.component.js"); |
57 | require("./content-viewer/content-viewer-actions.controller.js"); | 53 | require("./content-viewer/content-viewer-actions.controller.js"); |
58 | -// require("./content-viewer/content-viewer.controller.js"); | ||
59 | require("./profile/profile-home.controller.js"); | 54 | require("./profile/profile-home.controller.js"); |
60 | 55 | ||
61 | NoosferoApp.addController("ContentViewerController", noosferoContentViewer); | 56 | NoosferoApp.addController("ContentViewerController", noosferoContentViewer); |
62 | NoosferoApp.addController("ProfileController", noosferoProfile); | 57 | NoosferoApp.addController("ProfileController", noosferoProfile); |
63 | NoosferoApp.addController("ProfileInfoController", noosferoProfileInfo); | 58 | NoosferoApp.addController("ProfileInfoController", noosferoProfileInfo); |
59 | +NoosferoApp.addController("CmsController", noosferoCms); | ||
64 | 60 | ||
65 | NoosferoApp.addConfig(routeConfig); | 61 | NoosferoApp.addConfig(routeConfig); |
src/app/profile/profile.component.ts
1 | import {StateConfig, Component, Inject} from 'ng-forward'; | 1 | import {StateConfig, Component, Inject} from 'ng-forward'; |
2 | import {ProfileInfo} from '../profile-info/profile-info.component' | 2 | import {ProfileInfo} from '../profile-info/profile-info.component' |
3 | +import {Cms} from '../cms/cms.component' | ||
3 | 4 | ||
4 | @Component({ | 5 | @Component({ |
5 | selector: 'profile', | 6 | selector: 'profile', |
@@ -7,9 +8,9 @@ import {ProfileInfo} from '../profile-info/profile-info.component' | @@ -7,9 +8,9 @@ import {ProfileInfo} from '../profile-info/profile-info.component' | ||
7 | }) | 8 | }) |
8 | @StateConfig([ | 9 | @StateConfig([ |
9 | { | 10 | { |
11 | + name: 'main.profile.info', | ||
10 | url: "^/profile/:profile", | 12 | url: "^/profile/:profile", |
11 | component: ProfileInfo, | 13 | component: ProfileInfo, |
12 | - name: 'main.profile.info', | ||
13 | views: { | 14 | views: { |
14 | "mainBlockContent": { | 15 | "mainBlockContent": { |
15 | templateUrl: "app/profile-info/profile-info.html", | 16 | templateUrl: "app/profile-info/profile-info.html", |
@@ -17,7 +18,19 @@ import {ProfileInfo} from '../profile-info/profile-info.component' | @@ -17,7 +18,19 @@ import {ProfileInfo} from '../profile-info/profile-info.component' | ||
17 | controllerAs: "vm" | 18 | controllerAs: "vm" |
18 | } | 19 | } |
19 | } | 20 | } |
20 | - } | 21 | + }, |
22 | + { | ||
23 | + name: 'main.profile.cms', | ||
24 | + url: "^/myprofile/:profile/cms", | ||
25 | + component: Cms, | ||
26 | + views: { | ||
27 | + "mainBlockContent": { | ||
28 | + templateUrl: "app/cms/cms.html", | ||
29 | + controller: "CmsController", | ||
30 | + controllerAs: "vm" | ||
31 | + } | ||
32 | + } | ||
33 | + }, | ||
21 | ]) | 34 | ]) |
22 | @Inject("noosfero", "$log", "$stateParams") | 35 | @Inject("noosfero", "$log", "$stateParams") |
23 | export class Profile { | 36 | export class Profile { |