Save homepage

stable
Álex Hermida 2018-09-21 12:00:01 +02:00 committed by Alex Hermida
parent 2dc9835913
commit 417f9e97c7
3 changed files with 12 additions and 13 deletions

View File

@ -37,6 +37,11 @@ SECTIONS = {
} }
class SectionsService extends taiga.Service class SectionsService extends taiga.Service
@.$inject = ["$translate"]
constructor: (@translate) ->
super()
_.map(SECTIONS, (x) => x.title = @translate.instant("PROJECT.SECTION.#{x.title}"))
list: () -> list: () ->
return SECTIONS return SECTIONS

View File

@ -43,23 +43,21 @@ class UserProjectSettingsController extends mixOf(taiga.Controller, taiga.PageMi
] ]
constructor: (@scope, @tgSections, @rs, @repo, @confirm) -> constructor: (@scope, @tgSections, @rs, @repo, @confirm) ->
@scope.sections = @tgSections.list()
promise = @.loadInitialData() promise = @.loadInitialData()
promise.then null, @.onInitialDataError.bind(@) promise.then null, @.onInitialDataError.bind(@)
@scope.sections = @tgSections.list()
loadInitialData: -> loadInitialData: ->
return @rs.userProjectSettings.list().then (userProjectSettings) => return @rs.userProjectSettings.list().then (userProjectSettings) =>
@scope.userProjectSettings = userProjectSettings @scope.userProjectSettings = userProjectSettings
return userProjectSettings
updateCustomHomePage: (project, customHomePage) -> updateCustomHomePage: (projectSettings) ->
onSuccess = => onSuccess = =>
@confirm.notify("success") @confirm.notify("success")
onError = => onError = =>
@confirm.notify("error") @confirm.notify("error")
# @repo.save(project).then(onSuccess, onError) @repo.save(projectSettings).then(onSuccess, onError)
module.controller("UserProjectSettingsController", UserProjectSettingsController) module.controller("UserProjectSettingsController", UserProjectSettingsController)

View File

@ -27,11 +27,7 @@ div.wrapper(
.project-settings-table-homepage .project-settings-table-homepage
select( select(
id="projects-settings-{{projectSettings.id}}-homepage-dropdown" id="projects-settings-{{projectSettings.id}}-homepage-dropdown"
ng-model="projectSettings.homepage"
ng-options="section.id as section.title for section in sections"
ng-change="ctrl.updateCustomHomePage(projectSettings)"
) )
option(
ng-value="null"
) {{ 'USER_SETTINGS.PROJECT_SETTINGS.DEFAULT_VALUE' | translate }}
option(
ng-repeat="section in sections"
value="{{ section.id }}"
) {{ 'PROJECT.SECTION.' + section.title | translate }}