mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Templates state resets on modal close so if the api comes back it will work
This commit is contained in:
parent
735bc9e53d
commit
f3f53a99d0
2 changed files with 28 additions and 27 deletions
|
@ -14,14 +14,14 @@ script(type="text/ng-template", id="publishProjectAsTemplateModalTemplate")
|
||||||
textarea.form-control(
|
textarea.form-control(
|
||||||
rows=5,
|
rows=5,
|
||||||
name='Description',
|
name='Description',
|
||||||
ng-model="template.description",
|
ng-model="templateDetails.description",
|
||||||
ng-blur="updateProjectDescription()",
|
ng-blur="updateProjectDescription()",
|
||||||
value=""
|
value=""
|
||||||
)
|
)
|
||||||
div(ng-show="publishedDetails.exists").text-center.publishedDetails
|
div(ng-show="templateDetails.exists").text-center.templateDetails
|
||||||
| Your project was last published at
|
| Your project was last published at
|
||||||
strong {{publishedDetails.publishedDate}}.
|
strong {{templateDetails.publishedDate}}.
|
||||||
a(ng-href="{{publishedDetails.canonicalUrl}}") View it in template gallery.
|
a(ng-href="{{templateDetails.canonicalUrl}}") View it in template gallery.
|
||||||
|
|
||||||
span(ng-show="problemTalkingToTemplateApi") There is a problem with our publishing service, please try again in a few minutes.
|
span(ng-show="problemTalkingToTemplateApi") There is a problem with our publishing service, please try again in a few minutes.
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ script(type="text/ng-template", id="publishProjectAsTemplateModalTemplate")
|
||||||
button.btn.btn-info(
|
button.btn.btn-info(
|
||||||
ng-click="unpublishTemplate()",
|
ng-click="unpublishTemplate()",
|
||||||
ng-disabled="state.publishInflight || state.unpublishInflight"
|
ng-disabled="state.publishInflight || state.unpublishInflight"
|
||||||
ng-show="publishedDetails.exists"
|
ng-show="templateDetails.exists"
|
||||||
)
|
)
|
||||||
span(ng-show="!state.unpublishInflight") Unpublish
|
span(ng-show="!state.unpublishInflight") Unpublish
|
||||||
span(ng-show="state.unpublishInflight") Unpublishing...
|
span(ng-show="state.unpublishInflight") Unpublishing...
|
||||||
|
@ -47,6 +47,6 @@ script(type="text/ng-template", id="publishProjectAsTemplateModalTemplate")
|
||||||
ng-click="publishTemplate()",
|
ng-click="publishTemplate()",
|
||||||
ng-disabled="state.publishInflight || state.unpublishInflight"
|
ng-disabled="state.publishInflight || state.unpublishInflight"
|
||||||
)
|
)
|
||||||
span(ng-show="!state.publishInflight && !publishedDetails.exists") Publish
|
span(ng-show="!state.publishInflight && !templateDetails.exists") Publish
|
||||||
span(ng-show="!state.publishInflight && publishedDetails.exists") Republish
|
span(ng-show="!state.publishInflight && templateDetails.exists") Republish
|
||||||
span(ng-show="state.publishInflight") Publishing...
|
span(ng-show="state.publishInflight") Publishing...
|
|
@ -2,58 +2,59 @@ define [
|
||||||
"base"
|
"base"
|
||||||
"ide/permissions/PermissionsManager"
|
"ide/permissions/PermissionsManager"
|
||||||
], (App, PermissionsManager) ->
|
], (App, PermissionsManager) ->
|
||||||
|
|
||||||
App.controller "TemplatesController", ($scope, $modal, ide) ->
|
App.controller "TemplatesController", ($scope, $modal, ide) ->
|
||||||
$scope.openPublishTemplateModal = () ->
|
$scope.openPublishTemplateModal = () ->
|
||||||
$modal.open {
|
resetState = ->
|
||||||
|
$scope.problemTalkingToTemplateApi = false
|
||||||
|
|
||||||
|
resetState()
|
||||||
|
|
||||||
|
modal = $modal.open {
|
||||||
templateUrl: "publishProjectAsTemplateModalTemplate"
|
templateUrl: "publishProjectAsTemplateModalTemplate"
|
||||||
controller: "PublishProjectAsTemplateModalController"
|
controller: "PublishProjectAsTemplateModalController"
|
||||||
|
scope:$scope
|
||||||
}
|
}
|
||||||
|
modal.result.then(resetState, resetState)
|
||||||
|
|
||||||
App.controller "PublishProjectAsTemplateModalController", ($scope, $modalInstance, ide) ->
|
App.controller "PublishProjectAsTemplateModalController", ($scope, $modalInstance, ide) ->
|
||||||
|
|
||||||
user_id = ide.$scope.user.id
|
user_id = ide.$scope.user.id
|
||||||
$scope.template = {}
|
$scope.templateDetails = {exists:false}
|
||||||
$scope.publishedDetails =
|
|
||||||
exists:false
|
|
||||||
$scope.problemTalkingToTemplateApi = false
|
|
||||||
|
|
||||||
problemTalkingToTemplateApi = ->
|
|
||||||
$scope.problemTalkingToTemplateApi = true
|
|
||||||
|
|
||||||
successTalkingToTemplateApi = ->
|
|
||||||
$scope.problemTalkingToTemplateApi = true
|
|
||||||
|
|
||||||
$scope.state =
|
$scope.state =
|
||||||
publishInflight: false
|
publishInflight: false
|
||||||
unpublishInflight: false
|
unpublishInflight: false
|
||||||
|
|
||||||
refreshPublishedStatus = ->
|
problemTalkingToTemplateApi = ->
|
||||||
|
$scope.problemTalkingToTemplateApi = true
|
||||||
|
|
||||||
|
refreshPublishedStatus = ->
|
||||||
ide.socket.emit "getPublishedDetails", user_id, (err, data)->
|
ide.socket.emit "getPublishedDetails", user_id, (err, data)->
|
||||||
if !data? or err? then return problemTalkingToTemplateApi() else successTalkingToTemplateApi()
|
if !data? or err? then return problemTalkingToTemplateApi()
|
||||||
$scope.publishedDetails = data
|
$scope.templateDetails = data
|
||||||
$scope.publishedDetails.publishedDate = moment(data.publishedDate).format("Do MMM YYYY, h:mm a")
|
$scope.templateDetails.publishedDate = moment(data.publishedDate).format("Do MMM YYYY, h:mm a")
|
||||||
$scope.template.description = data.description
|
$scope.templateDetails.description = data.description
|
||||||
|
|
||||||
refreshPublishedStatus()
|
refreshPublishedStatus()
|
||||||
|
$scope.$watch $scope.problemTalkingToTemplateApi, refreshPublishedStatus
|
||||||
|
|
||||||
$scope.updateProjectDescription = ->
|
$scope.updateProjectDescription = ->
|
||||||
description = $scope.template.description
|
description = $scope.template.description
|
||||||
if description?
|
if description?
|
||||||
ide.socket.emit 'updateProjectDescription', description, (err) =>
|
ide.socket.emit 'updateProjectDescription', description, (err) =>
|
||||||
if err? then return problemTalkingToTemplateApi() else successTalkingToTemplateApi()
|
if err? then return problemTalkingToTemplateApi()
|
||||||
|
|
||||||
$scope.publishTemplate = ->
|
$scope.publishTemplate = ->
|
||||||
$scope.state.publishInflight = true
|
$scope.state.publishInflight = true
|
||||||
ide.socket.emit 'publishProjectAsTemplate', user_id, (error) =>
|
ide.socket.emit 'publishProjectAsTemplate', user_id, (error) =>
|
||||||
if err? then return problemTalkingToTemplateApi() else successTalkingToTemplateApi()
|
if err? then return problemTalkingToTemplateApi()
|
||||||
refreshPublishedStatus()
|
refreshPublishedStatus()
|
||||||
$scope.state.publishInflight = false
|
$scope.state.publishInflight = false
|
||||||
|
|
||||||
$scope.unpublishTemplate = ->
|
$scope.unpublishTemplate = ->
|
||||||
$scope.state.unpublishInflight = true
|
$scope.state.unpublishInflight = true
|
||||||
ide.socket.emit 'unPublishProjectAsTemplate', user_id, (error) =>
|
ide.socket.emit 'unPublishProjectAsTemplate', user_id, (error) =>
|
||||||
if err? then return problemTalkingToTemplateApi() else successTalkingToTemplateApi()
|
if err? then return problemTalkingToTemplateApi()
|
||||||
refreshPublishedStatus()
|
refreshPublishedStatus()
|
||||||
$scope.state.unpublishInflight = false
|
$scope.state.unpublishInflight = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue