From 65a721944518e9df9373ca42617089e217970c56 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Tue, 1 Mar 2016 10:10:57 -0300 Subject: [PATCH] Migrate profile controller --- src/app/cms/cms.component.ts | 36 ++++++++++++++++++++++++++++++++++++ src/app/cms/cms.controller.js | 35 ----------------------------------- src/app/index.route.ts | 10 ---------- src/app/index.ts | 10 +++------- src/app/profile/profile.component.ts | 17 +++++++++++++++-- 5 files changed, 54 insertions(+), 54 deletions(-) create mode 100644 src/app/cms/cms.component.ts delete mode 100644 src/app/cms/cms.controller.js diff --git a/src/app/cms/cms.component.ts b/src/app/cms/cms.component.ts new file mode 100644 index 0000000..7c35f21 --- /dev/null +++ b/src/app/cms/cms.component.ts @@ -0,0 +1,36 @@ +import {StateConfig, Component, Inject} from 'ng-forward'; + +@Component({ + selector: 'cms', + templateUrl: "app/cms/cms.html" +}) +@Inject("noosfero", "$stateParams", "$httpParamSerializer", "$state", "SweetAlert") +export class Cms { + + article: any = {}; + profile: any; + + constructor(private noosfero, private $stateParams, private $httpParamSerializer, private $state, private SweetAlert) { + + } + + save() { + this.noosfero.currentProfile.then((profile) => { + return this.noosfero.profiles.one(profile.id).customPOST( + { article: this.article }, + 'articles', + {}, + { 'Content-Type': 'application/json' } + ) + }).then((response) => { + this.$state.transitionTo('main.profile.page', { page: response.data.article.path, profile: response.data.article.profile.identifier }); + this.SweetAlert.swal({ + title: "Good job!", + text: "Article saved!", + type: "success", + timer: 1000 + }); + }); + } + +} diff --git a/src/app/cms/cms.controller.js b/src/app/cms/cms.controller.js deleted file mode 100644 index 4a4b06c..0000000 --- a/src/app/cms/cms.controller.js +++ /dev/null @@ -1,35 +0,0 @@ -(function() { - 'use strict'; - - angular - .module('noosferoApp') - .controller('CmsController', CmsController); - - - /** @ngInject */ - function CmsController(noosfero, $stateParams, $httpParamSerializer, $state, SweetAlert) { - var vm = this; - vm.article = {}; - vm.profile = null; - - vm.save = function() { - noosfero.currentProfile.then(function(profile) { - return noosfero.profiles.one(profile.id).customPOST( - {article: vm.article}, - 'articles', - {}, - {'Content-Type':'application/json'} - ) - }).then(function(response) { - $state.transitionTo('main.profile.page', {page: response.data.article.path, profile: response.data.article.profile.identifier}); - SweetAlert.swal({ - title: "Good job!", - text: "Article saved!", - type: "success", - timer: 1000 - }); - }); - } - - } -})(); diff --git a/src/app/index.route.ts b/src/app/index.route.ts index 7ca7686..6bd6762 100644 --- a/src/app/index.route.ts +++ b/src/app/index.route.ts @@ -3,16 +3,6 @@ /** @ngInject */ export function routeConfig($stateProvider, $urlRouterProvider) { $stateProvider - .state("main.profile.cms", { - url: "^/myprofile/:profile/cms", - views: { - "mainBlockContent": { - templateUrl: "app/cms/cms.html", - controller: "CmsController", - controllerAs: "vm" - } - } - }) .state("main.profile.settings", { url: "^/myprofile/:profile" }) diff --git a/src/app/index.ts b/src/app/index.ts index e4534ec..8108693 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -8,13 +8,14 @@ import {routeConfig} from "./index.route"; import {ContentViewer as noosferoContentViewer} from "./content-viewer/content-viewer.component"; import {Profile as noosferoProfile} from "./profile/profile.component"; import {ProfileInfo as noosferoProfileInfo} from "./profile-info/profile-info.component"; +import {Cms as noosferoCms} from "./cms/cms.component"; import {Main} from "./main/main.component"; import {bootstrap, bundle} from "ng-forward"; -declare var moment: any; +declare var moment: any; let noosferoApp: any = bundle("noosferoApp", Main, ["ngAnimate", "ngCookies", "ngStorage", "ngTouch", "ngSanitize", "ngMessages", "ngAria", "restangular", @@ -34,16 +35,11 @@ NoosferoApp.addConstants("AUTH_EVENTS", { NoosferoApp.addConfig(noosferoModuleConfig); NoosferoApp.run(noosferoAngularRunBlock); -require("./cms/cms.controller.js"); require("./components/auth/auth.controller.js"); require("./components/auth/auth.service.js"); require("./components/navbar/navbar.directive.js"); require("./components/noosfero-activities/activities.component.js"); require("./components/noosfero-activities/activity/activity.component.js"); - -// require("./components/noosfero-articles/blog/blog.component.js"); - - require("./components/noosfero-blocks/block.directive.js"); require("./components/noosfero-blocks/link-list/link-list.component.js"); require("./components/noosfero-blocks/main-block/main-block.component.js"); @@ -55,11 +51,11 @@ require("./components/noosfero/noosfero-template.filter.js"); require("./components/noosfero/noosfero.service.js"); require("./components/noosfero/profile-image/profile-image.component.js"); require("./content-viewer/content-viewer-actions.controller.js"); -// require("./content-viewer/content-viewer.controller.js"); require("./profile/profile-home.controller.js"); NoosferoApp.addController("ContentViewerController", noosferoContentViewer); NoosferoApp.addController("ProfileController", noosferoProfile); NoosferoApp.addController("ProfileInfoController", noosferoProfileInfo); +NoosferoApp.addController("CmsController", noosferoCms); NoosferoApp.addConfig(routeConfig); diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index 9eb8970..88b237d 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -1,5 +1,6 @@ import {StateConfig, Component, Inject} from 'ng-forward'; import {ProfileInfo} from '../profile-info/profile-info.component' +import {Cms} from '../cms/cms.component' @Component({ selector: 'profile', @@ -7,9 +8,9 @@ import {ProfileInfo} from '../profile-info/profile-info.component' }) @StateConfig([ { + name: 'main.profile.info', url: "^/profile/:profile", component: ProfileInfo, - name: 'main.profile.info', views: { "mainBlockContent": { templateUrl: "app/profile-info/profile-info.html", @@ -17,7 +18,19 @@ import {ProfileInfo} from '../profile-info/profile-info.component' controllerAs: "vm" } } - } + }, + { + name: 'main.profile.cms', + url: "^/myprofile/:profile/cms", + component: Cms, + views: { + "mainBlockContent": { + templateUrl: "app/cms/cms.html", + controller: "CmsController", + controllerAs: "vm" + } + } + }, ]) @Inject("noosfero", "$log", "$stateParams") export class Profile { -- libgit2 0.21.2