mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 06:05:30 -05:00
Move template front end code to module
This commit is contained in:
parent
01cf220d57
commit
b44e9b1dcb
4 changed files with 1 additions and 93 deletions
|
@ -41,10 +41,7 @@ aside#left-menu.full-size(
|
||||||
)
|
)
|
||||||
i.fa.fa-fw.fa-copy
|
i.fa.fa-fw.fa-copy
|
||||||
| #{translate("copy_project")}
|
| #{translate("copy_project")}
|
||||||
li(ng-controller="TemplatesController", ng-show="permissions.admin")
|
!{moduleIncludes("editorLeftMenu:actions", locals)}
|
||||||
a(ng-click="openPublishTemplateModal()")
|
|
||||||
i.fa.fa-external-link.fa-fw
|
|
||||||
| #{translate("publish_as_template")}
|
|
||||||
|
|
||||||
if (moduleIncludesAvailable("editorLeftMenu:sync"))
|
if (moduleIncludesAvailable("editorLeftMenu:sync"))
|
||||||
div(ng-show="!anonymous")
|
div(ng-show="!anonymous")
|
||||||
|
|
|
@ -12,7 +12,6 @@ define [
|
||||||
"ide/share/index"
|
"ide/share/index"
|
||||||
"ide/chat/index"
|
"ide/chat/index"
|
||||||
"ide/clone/index"
|
"ide/clone/index"
|
||||||
"ide/templates/index"
|
|
||||||
"ide/dropbox/index"
|
"ide/dropbox/index"
|
||||||
"ide/hotkeys/index"
|
"ide/hotkeys/index"
|
||||||
"ide/directives/layout"
|
"ide/directives/layout"
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
define [
|
|
||||||
"base"
|
|
||||||
"ide/permissions/PermissionsManager"
|
|
||||||
], (App, PermissionsManager) ->
|
|
||||||
|
|
||||||
App.controller "TemplatesController", ($scope, $modal, ide) ->
|
|
||||||
$scope.openPublishTemplateModal = () ->
|
|
||||||
resetState = ->
|
|
||||||
$scope.problemTalkingToTemplateApi = false
|
|
||||||
|
|
||||||
resetState()
|
|
||||||
|
|
||||||
modal = $modal.open {
|
|
||||||
templateUrl: "publishProjectAsTemplateModalTemplate"
|
|
||||||
controller: "PublishProjectAsTemplateModalController"
|
|
||||||
scope:$scope
|
|
||||||
}
|
|
||||||
modal.result.then(resetState, resetState)
|
|
||||||
|
|
||||||
App.controller "PublishProjectAsTemplateModalController", ($scope, $modalInstance, ide, $http) ->
|
|
||||||
user_id = ide.$scope.user.id
|
|
||||||
$scope.templateDetails = {exists:false}
|
|
||||||
|
|
||||||
$scope.state =
|
|
||||||
publishInflight: false
|
|
||||||
unpublishInflight: false
|
|
||||||
|
|
||||||
problemTalkingToTemplateApi = ->
|
|
||||||
$scope.problemTalkingToTemplateApi = true
|
|
||||||
|
|
||||||
refreshPublishedStatus = ->
|
|
||||||
$http.get("/project/#{ide.project_id}/template")
|
|
||||||
.success (data) ->
|
|
||||||
$scope.templateDetails = data
|
|
||||||
$scope.templateDetails.publishedDate = moment(data.publishedDate).format("Do MMM YYYY, h:mm a")
|
|
||||||
$scope.templateDetails.description = data.description
|
|
||||||
.error () ->
|
|
||||||
problemTalkingToTemplateApi()
|
|
||||||
|
|
||||||
refreshPublishedStatus()
|
|
||||||
$scope.$watch $scope.problemTalkingToTemplateApi, (value) ->
|
|
||||||
if value?
|
|
||||||
refreshPublishedStatus()
|
|
||||||
|
|
||||||
updateProjectDescription = ->
|
|
||||||
$http.post("/project/#{ide.project_id}/template/description", {
|
|
||||||
description: $scope.templateDetails.description
|
|
||||||
_csrf: window.csrfToken
|
|
||||||
})
|
|
||||||
|
|
||||||
# Save the description on modal close
|
|
||||||
$modalInstance.result.finally () -> updateProjectDescription()
|
|
||||||
|
|
||||||
$scope.publishTemplate = ->
|
|
||||||
$scope.state.publishInflight = true
|
|
||||||
updateProjectDescription()
|
|
||||||
.error () ->
|
|
||||||
problemTalkingToTemplateApi()
|
|
||||||
.success () ->
|
|
||||||
$http
|
|
||||||
.post("/project/#{ide.project_id}/template/publish", {
|
|
||||||
_csrf: window.csrfToken
|
|
||||||
})
|
|
||||||
.error () ->
|
|
||||||
problemTalkingToTemplateApi()
|
|
||||||
.success () ->
|
|
||||||
refreshPublishedStatus()
|
|
||||||
$scope.state.publishInflight = false
|
|
||||||
|
|
||||||
|
|
||||||
$scope.unpublishTemplate = ->
|
|
||||||
$scope.state.unpublishInflight = true
|
|
||||||
$http
|
|
||||||
.post("/project/#{ide.project_id}/template/unpublish", {
|
|
||||||
_csrf: window.csrfToken
|
|
||||||
})
|
|
||||||
.success () ->
|
|
||||||
refreshPublishedStatus()
|
|
||||||
$scope.state.unpublishInflight = false
|
|
||||||
.error () ->
|
|
||||||
problemTalkingToTemplateApi()
|
|
||||||
|
|
||||||
$scope.cancel = () ->
|
|
||||||
$modalInstance.dismiss()
|
|
|
@ -1,4 +0,0 @@
|
||||||
define [
|
|
||||||
"ide/templates/controllers/TemplatesController"
|
|
||||||
], () ->
|
|
||||||
|
|
Loading…
Reference in a new issue