Improve the new plugin system
parent
d1af25a596
commit
f6cf6d227c
|
@ -1,4 +1,5 @@
|
||||||
window._version = "___VERSION___"
|
window._version = "___VERSION___"
|
||||||
|
|
||||||
window.taigaConfig = {
|
window.taigaConfig = {
|
||||||
"api": "http://localhost:8000/api/v1/",
|
"api": "http://localhost:8000/api/v1/",
|
||||||
"eventsUrl": null,
|
"eventsUrl": null,
|
||||||
|
@ -15,7 +16,10 @@ window.taigaConfig = {
|
||||||
"maxUploadFileSize": null,
|
"maxUploadFileSize": null,
|
||||||
"contribPlugins": []
|
"contribPlugins": []
|
||||||
}
|
}
|
||||||
window._decorators= []
|
|
||||||
|
window.taigaContribPlugins = []
|
||||||
|
|
||||||
|
window._decorators = []
|
||||||
|
|
||||||
window.addDecorator = (provider, decorator) ->
|
window.addDecorator = (provider, decorator) ->
|
||||||
window._decorators.push({provider: provider, decorator: decorator})
|
window._decorators.push({provider: provider, decorator: decorator})
|
||||||
|
@ -29,6 +33,8 @@ loadStylesheet = (path) ->
|
||||||
loadPlugin = (pluginPath) ->
|
loadPlugin = (pluginPath) ->
|
||||||
return new Promise (resolve, reject) ->
|
return new Promise (resolve, reject) ->
|
||||||
$.getJSON(pluginPath).then (plugin) ->
|
$.getJSON(pluginPath).then (plugin) ->
|
||||||
|
window.taigaContribPlugins.push(plugin)
|
||||||
|
|
||||||
if plugin.css
|
if plugin.css
|
||||||
loadStylesheet(plugin.css)
|
loadStylesheet(plugin.css)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
###
|
###
|
||||||
|
|
||||||
@taiga = taiga = {}
|
@taiga = taiga = {}
|
||||||
@.taigaContribPlugins = @.taigaContribPlugins or []
|
@.taigaContribPlugins = @.taigaContribPlugins or window.taigaContribPlugins or []
|
||||||
|
|
||||||
# Generic function for generate hash from a arbitrary length
|
# Generic function for generate hash from a arbitrary length
|
||||||
# collection of parameters.
|
# collection of parameters.
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
# File: modules/base/contrib.coffee
|
# File: modules/base/contrib.coffee
|
||||||
###
|
###
|
||||||
|
|
||||||
taigaContribPlugins = @.taigaContribPlugins = @.taigaContribPlugins or []
|
module = angular.module("taigaBase")
|
||||||
|
|
||||||
|
|
||||||
class ContribController extends taiga.Controller
|
class ContribController extends taiga.Controller
|
||||||
@.$inject = [
|
@.$inject = [
|
||||||
|
@ -32,9 +33,7 @@ class ContribController extends taiga.Controller
|
||||||
]
|
]
|
||||||
|
|
||||||
constructor: (@rootScope, @scope, @params, @repo, @rs, @confirm) ->
|
constructor: (@rootScope, @scope, @params, @repo, @rs, @confirm) ->
|
||||||
@scope.adminPlugins = _.where(@rootScope.contribPlugins, {"type": "admin"})
|
@scope.currentPlugin = _.first(_.where(@rootScope.adminPlugins, {"slug": @params.plugin}))
|
||||||
@scope.currentPlugin = _.first(_.where(@scope.adminPlugins, {"slug": @params.plugin}))
|
|
||||||
@scope.pluginTemplate = "contrib/#{@scope.currentPlugin.slug}"
|
|
||||||
@scope.projectSlug = @params.pslug
|
@scope.projectSlug = @params.pslug
|
||||||
|
|
||||||
promise = @.loadInitialData()
|
promise = @.loadInitialData()
|
||||||
|
@ -53,5 +52,4 @@ class ContribController extends taiga.Controller
|
||||||
loadInitialData: ->
|
loadInitialData: ->
|
||||||
return @.loadProject()
|
return @.loadProject()
|
||||||
|
|
||||||
module = angular.module("taigaBase")
|
|
||||||
module.controller("ContribController", ContribController)
|
module.controller("ContribController", ContribController)
|
||||||
|
|
|
@ -9,4 +9,4 @@ div.wrapper.roles(ng-init="section='admin'", ng-controller="ContribController as
|
||||||
sidebar.menu-tertiary.sidebar
|
sidebar.menu-tertiary.sidebar
|
||||||
include ../includes/modules/admin/admin-submenu-contrib
|
include ../includes/modules/admin/admin-submenu-contrib
|
||||||
|
|
||||||
section.main.admin-common.admin-contrib(ng-include="pluginTemplate")
|
section.main.admin-common.admin-contrib(ng-include="currentPlugin.template")
|
||||||
|
|
|
@ -2,5 +2,9 @@ section.admin-submenu
|
||||||
nav
|
nav
|
||||||
ul
|
ul
|
||||||
li#adminmenu-contrib(ng-repeat="plugin in adminPlugins")
|
li#adminmenu-contrib(ng-repeat="plugin in adminPlugins")
|
||||||
a(href="", tg-nav="project-admin-contrib:project=projectSlug,plugin=plugin.slug" ng-class="{active: plugin.slug == currentPlugin.slug}")
|
a(
|
||||||
|
href=""
|
||||||
|
tg-nav="project-admin-contrib:project=projectSlug,plugin=plugin.slug"
|
||||||
|
ng-class="{active: plugin.slug == currentPlugin.slug}"
|
||||||
|
)
|
||||||
span.title {{ plugin.name }}
|
span.title {{ plugin.name }}
|
||||||
|
|
Loading…
Reference in New Issue