From 6eae1d59ea09d870c74712d866d093be37248aca Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 29 Nov 2017 14:07:29 +0000 Subject: [PATCH] Use asyncForm directive to trigger import --- .../web/app/views/project/list/modals.pug | 21 +++++++++++++++++-- .../project-list/modal-controllers.coffee | 3 --- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/services/web/app/views/project/list/modals.pug b/services/web/app/views/project/list/modals.pug index 828fa9fe4b..27bfcdd914 100644 --- a/services/web/app/views/project/list/modals.pug +++ b/services/web/app/views/project/list/modals.pug @@ -340,11 +340,28 @@ script(type="text/ng-template", id="v1ImportModalTemplate") h2.v1-import-title #[strong Warning:] Overleaf V2 is in beta p Once importing your project you will lose access to the some of the features of Overleaf V1. This includes the git bridge, journal integrations, WYSIWYG and linked files. We’re working on bringing these features to V2! p Once you have imported a project to V2 you #[strong cannot go back to V1]. + p Are you sure you want to import to V2? .modal-footer.v1-import-footer div(ng-show="step === 1") a.btn.btn-primary.v1-import-btn(ng-href=settings.overleaf.host + "/{{project.id}}") #{translate("open_in_v1")} button.btn.btn-primary.v1-import-btn(ng-click="moveToConfirmation()") #{translate("import_to_v2")} div(ng-show="step === 2") - a.btn.btn-primary.v1-import-btn(ng-href=settings.overleaf.host + "/{{project.id}}") #{translate("never_mind_open_in_v1")} - button.btn.btn-primary.v1-import-btn(ng-click="import()") #{translate("yes_im_sure")} + form( + async-form="v1Import", + name="v1ImportForm", + action="{{'/overleaf/project/'+ project.id + '/import'}}" + method="POST" + ng-cloak + ) + input(name='_csrf', type='hidden', value=csrfToken) + form-messages(for="v1ImportForm") + a.btn.btn-primary.v1-import-btn( + ng-href=settings.overleaf.host + "/{{project.id}}" + ng-class="{disabled: v1ImportForm.inflight || v1ImportForm.success}" + ) #{translate("never_mind_open_in_v1")} + input.btn.btn-primary.v1-import-btn( + type="submit", + value=translate('yes_im_sure') + ng-disabled="v1ImportForm.inflight || v1ImportForm.success" + ) diff --git a/services/web/public/coffee/main/project-list/modal-controllers.coffee b/services/web/public/coffee/main/project-list/modal-controllers.coffee index 5fd0a4707d..609a16cb77 100644 --- a/services/web/public/coffee/main/project-list/modal-controllers.coffee +++ b/services/web/public/coffee/main/project-list/modal-controllers.coffee @@ -133,6 +133,3 @@ define [ $scope.moveToConfirmation = () -> $scope.step = 2 - - $scope.import = () -> - console.log('IMPORT', project)