defineImmutableProperty
parent
37a0e59fd6
commit
3f34ed1412
|
@ -158,6 +158,15 @@ replaceTags = (str, tags, replace) ->
|
|||
|
||||
return str
|
||||
|
||||
defineImmutableProperty = (obj, name, variable) =>
|
||||
Object.defineProperty obj, name, {
|
||||
get: () =>
|
||||
if _.isFunction(variable)
|
||||
return variable.call(obj)
|
||||
else
|
||||
return variable
|
||||
}
|
||||
|
||||
taiga = @.taiga
|
||||
taiga.nl2br = nl2br
|
||||
taiga.bindMethods = bindMethods
|
||||
|
@ -179,3 +188,4 @@ taiga.startswith = startswith
|
|||
taiga.sizeFormat = sizeFormat
|
||||
taiga.stripTags = stripTags
|
||||
taiga.replaceTags = replaceTags
|
||||
taiga.defineImmutableProperty = defineImmutableProperty
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
DropdownProjectListDirective = (projectsService) ->
|
||||
link = (scope, el, attrs, ctrl) ->
|
||||
scope.vm = {}
|
||||
scope.vm.projects = projectsService.projects
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", projectsService.projects)
|
||||
scope.vm.newProject = ->
|
||||
projectsService.newProject()
|
||||
|
||||
|
||||
directive = {
|
||||
templateUrl: "navigation-bar/dropdown-project-list/dropdown-project-list.html"
|
||||
scope: {}
|
||||
|
|
|
@ -25,7 +25,7 @@ ProjectsListingDirective = (projectsService) ->
|
|||
|
||||
projectsService.bulkUpdateProjectsOrder(sortData)
|
||||
|
||||
scope.vm.projects = projectsService.projects
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", projectsService.projects)
|
||||
|
||||
scope.vm.newProject = ->
|
||||
projectsService.newProject()
|
||||
|
|
Loading…
Reference in New Issue