mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
WIP
This commit is contained in:
parent
d36dbfda07
commit
60ca298db3
5 changed files with 80 additions and 15 deletions
|
@ -345,7 +345,7 @@ script(type='text/ng-template', id='newDocModalTemplate')
|
||||||
// Project Linked Files Modal
|
// Project Linked Files Modal
|
||||||
script(type='text/ng-template', id='projectLinkedFileModalTemplate')
|
script(type='text/ng-template', id='projectLinkedFileModalTemplate')
|
||||||
.modal-header
|
.modal-header
|
||||||
h3 New file from Project
|
h3 New file from Project ({{ isOutputFiles }})
|
||||||
|
|
||||||
.modal-body
|
.modal-body
|
||||||
div
|
div
|
||||||
|
|
|
@ -73,6 +73,10 @@ aside#left-menu.full-size(
|
||||||
a(href="#" ng-click="openProjectLinkedFileModal()")
|
a(href="#" ng-click="openProjectLinkedFileModal()")
|
||||||
i.fa.fa-exclamation.fa-fw
|
i.fa.fa-exclamation.fa-fw
|
||||||
| Project-Linked-File Modal
|
| Project-Linked-File Modal
|
||||||
|
li
|
||||||
|
a(href="#" ng-click="openProjectOutputLinkedFileModal()")
|
||||||
|
i.fa.fa-exclamation.fa-fw
|
||||||
|
| Project-Output-Linked-File Modal
|
||||||
li
|
li
|
||||||
a(href="#" ng-click="openLinkedFileModal()")
|
a(href="#" ng-click="openLinkedFileModal()")
|
||||||
i.fa.fa-exclamation.fa-fw
|
i.fa.fa-exclamation.fa-fw
|
||||||
|
|
|
@ -53,6 +53,21 @@ define [
|
||||||
scope: $scope
|
scope: $scope
|
||||||
resolve: {
|
resolve: {
|
||||||
parent_folder: () -> ide.fileTreeManager.getCurrentFolder()
|
parent_folder: () -> ide.fileTreeManager.getCurrentFolder()
|
||||||
|
isOutputFiles: () -> false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
$scope.openProjectOutputLinkedFileModal = window.openProjectOutputLinkedFileModal = () ->
|
||||||
|
unless 'project_output_file' in window.data.enabledLinkedFileTypes
|
||||||
|
console.warn("Project linked output files are not enabled")
|
||||||
|
return
|
||||||
|
$modal.open(
|
||||||
|
templateUrl: "projectLinkedFileModalTemplate"
|
||||||
|
controller: "ProjectLinkedFileModalController"
|
||||||
|
scope: $scope
|
||||||
|
resolve: {
|
||||||
|
parent_folder: () -> ide.fileTreeManager.getCurrentFolder()
|
||||||
|
isOutputFiles: () -> true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -215,25 +230,33 @@ define [
|
||||||
]
|
]
|
||||||
|
|
||||||
App.controller "ProjectLinkedFileModalController", [
|
App.controller "ProjectLinkedFileModalController", [
|
||||||
"$scope", "ide", "$modalInstance", "$timeout", "parent_folder",
|
"$scope", "ide", "$modalInstance", "$timeout", "parent_folder", "isOutputFiles",
|
||||||
($scope, ide, $modalInstance, $timeout, parent_folder) ->
|
($scope, ide, $modalInstance, $timeout, parent_folder, isOutputFiles) ->
|
||||||
|
$scope.isOutputFiles = isOutputFiles
|
||||||
|
console.log ">>>> LINKED", isOutputFiles
|
||||||
|
|
||||||
$scope.data =
|
$scope.data =
|
||||||
projects: null # or []
|
projects: null # or []
|
||||||
selectedProjectId: null
|
selectedProjectId: null
|
||||||
projectEntities: null # or []
|
projectEntities: null # or []
|
||||||
|
projectOutputFiles: null # or []
|
||||||
selectedProjectEntity: null
|
selectedProjectEntity: null
|
||||||
name: null
|
name: null
|
||||||
$scope.state =
|
$scope.state =
|
||||||
inFlight:
|
inFlight:
|
||||||
projects: false
|
projects: false
|
||||||
entities: false
|
entities: false
|
||||||
|
compile: false
|
||||||
create: false
|
create: false
|
||||||
error: false
|
error: false
|
||||||
|
|
||||||
$scope.$watch 'data.selectedProjectId', (newVal, oldVal) ->
|
$scope.$watch 'data.selectedProjectId', (newVal, oldVal) ->
|
||||||
return if !newVal
|
return if !newVal
|
||||||
$scope.data.selectedProjectEntity = null
|
$scope.data.selectedProjectEntity = null
|
||||||
$scope.getProjectEntities($scope.data.selectedProjectId)
|
if isOutputFiles
|
||||||
|
$scope.compileProjectAndGetOutputFiles($scope.data.selectedProjectId)
|
||||||
|
else
|
||||||
|
$scope.getProjectEntities($scope.data.selectedProjectId)
|
||||||
|
|
||||||
# auto-set filename based on selected file
|
# auto-set filename based on selected file
|
||||||
$scope.$watch 'data.selectedProjectEntity', (newVal, oldVal) ->
|
$scope.$watch 'data.selectedProjectEntity', (newVal, oldVal) ->
|
||||||
|
@ -248,7 +271,7 @@ define [
|
||||||
_reset = (opts) ->
|
_reset = (opts) ->
|
||||||
isError = opts.err == true
|
isError = opts.err == true
|
||||||
inFlight = $scope.state.inFlight
|
inFlight = $scope.state.inFlight
|
||||||
inFlight.projects = inFlight.entities = inFlight.create = false
|
inFlight.projects = inFlight.entities = inFlight.compile = inFlight.create = false
|
||||||
$scope.state.error = isError
|
$scope.state.error = isError
|
||||||
|
|
||||||
$scope.shouldEnableProjectSelect = () ->
|
$scope.shouldEnableProjectSelect = () ->
|
||||||
|
@ -259,6 +282,10 @@ define [
|
||||||
{ state, data } = $scope
|
{ state, data } = $scope
|
||||||
return !state.inFlight.projects && !state.inFlight.entities && data.projects && data.selectedProjectId
|
return !state.inFlight.projects && !state.inFlight.entities && data.projects && data.selectedProjectId
|
||||||
|
|
||||||
|
$scope.shouldEnableProjectOutputFileSelect = () ->
|
||||||
|
{ state, data } = $scope
|
||||||
|
return !state.inFlight.projects && !state.inFlight.compile && data.projects && data.selectedProjectId
|
||||||
|
|
||||||
$scope.shouldEnableCreateButton = () ->
|
$scope.shouldEnableCreateButton = () ->
|
||||||
state = $scope.state
|
state = $scope.state
|
||||||
data = $scope.data
|
data = $scope.data
|
||||||
|
@ -266,8 +293,18 @@ define [
|
||||||
!state.inFlight.entities &&
|
!state.inFlight.entities &&
|
||||||
data.projects &&
|
data.projects &&
|
||||||
data.selectedProjectId &&
|
data.selectedProjectId &&
|
||||||
data.projectEntities &&
|
(
|
||||||
data.selectedProjectEntity &&
|
(
|
||||||
|
!isOutputFiles &&
|
||||||
|
data.projectEntities &&
|
||||||
|
data.selectedProjectEntity
|
||||||
|
) ||
|
||||||
|
(
|
||||||
|
isOutputFiles &&
|
||||||
|
data.projectOutputFiles &&
|
||||||
|
data.selectedProjectOutputFile
|
||||||
|
)
|
||||||
|
) &&
|
||||||
data.name
|
data.name
|
||||||
|
|
||||||
$scope.getUserProjects = () ->
|
$scope.getUserProjects = () ->
|
||||||
|
@ -295,23 +332,43 @@ define [
|
||||||
.catch (err) ->
|
.catch (err) ->
|
||||||
_reset(err: true)
|
_reset(err: true)
|
||||||
|
|
||||||
|
window._C = $scope.compileProjectAndGetOutputFiles = (project_id) =>
|
||||||
|
_setInFlight('compile')
|
||||||
|
$http.post("/project/${project_id}/compile", {
|
||||||
|
check: "silent",
|
||||||
|
draft: false,
|
||||||
|
incrementalCompilesEnabled: false
|
||||||
|
_csrf: window.csrfToken
|
||||||
|
})
|
||||||
|
.then (data) ->
|
||||||
|
console.log ">> COMPILE", data
|
||||||
|
_reset(err: false)
|
||||||
|
.catch (err) ->
|
||||||
|
console.error(err)
|
||||||
|
_reset(err: true)
|
||||||
|
|
||||||
$scope.init = () ->
|
$scope.init = () ->
|
||||||
$scope.getUserProjects()
|
$scope.getUserProjects()
|
||||||
$timeout($scope.init, 0)
|
$timeout($scope.init, 0)
|
||||||
|
|
||||||
$scope.create = () ->
|
$scope.create = () ->
|
||||||
projectId = $scope.data.selectedProjectId
|
projectId = $scope.data.selectedProjectId
|
||||||
path = $scope.data.selectedProjectEntity
|
|
||||||
name = $scope.data.name
|
name = $scope.data.name
|
||||||
if !name || !path || !projectId
|
if isOutputFiles
|
||||||
_reset(err: true)
|
provider = 'project_output_file'
|
||||||
return
|
payload = {
|
||||||
|
source_project_id: projectId,
|
||||||
|
source_output_file_path: $scope.data.selectedProjectOutputFile
|
||||||
|
}
|
||||||
|
else
|
||||||
|
provider = 'project_file'
|
||||||
|
payload = {
|
||||||
|
source_project_id: projectId,
|
||||||
|
source_entity_path: $scope.data.selectedProjectEntity
|
||||||
|
}
|
||||||
_setInFlight('create')
|
_setInFlight('create')
|
||||||
ide.fileTreeManager
|
ide.fileTreeManager
|
||||||
.createLinkedFile(name, parent_folder, 'project_file', {
|
.createLinkedFile(name, parent_folder, provider, payload)
|
||||||
source_project_id: projectId,
|
|
||||||
source_entity_path: path
|
|
||||||
})
|
|
||||||
.then () ->
|
.then () ->
|
||||||
_reset(err: false)
|
_reset(err: false)
|
||||||
$modalInstance.close()
|
$modalInstance.close()
|
||||||
|
|
|
@ -524,6 +524,7 @@ define [
|
||||||
{ data } = response
|
{ data } = response
|
||||||
$scope.pdf.view = "pdf"
|
$scope.pdf.view = "pdf"
|
||||||
$scope.pdf.compiling = false
|
$scope.pdf.compiling = false
|
||||||
|
console.log ">>", data
|
||||||
parseCompileResponse(data)
|
parseCompileResponse(data)
|
||||||
.catch (response) ->
|
.catch (response) ->
|
||||||
{ data, status } = response
|
{ data, status } = response
|
||||||
|
|
|
@ -7,6 +7,9 @@ define [
|
||||||
$scope.openProjectLinkedFileModal = () ->
|
$scope.openProjectLinkedFileModal = () ->
|
||||||
window.openProjectLinkedFileModal()
|
window.openProjectLinkedFileModal()
|
||||||
|
|
||||||
|
$scope.openProjectOutputLinkedFileModal = () ->
|
||||||
|
window.openProjectOutputLinkedFileModal()
|
||||||
|
|
||||||
$scope.openLinkedFileModal = () ->
|
$scope.openLinkedFileModal = () ->
|
||||||
window.openLinkedFileModal()
|
window.openLinkedFileModal()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue