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