diff --git a/.eslintrc.js b/.eslintrc.js index 7c719f95e..202a3f642 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -36,6 +36,7 @@ module.exports = { 'jQuery': true, 'tainacan_extra_components': true, 'tainacan_extra_plugins': true, - 'grecaptcha': true + 'grecaptcha': true, + 'webkit': true } } \ No newline at end of file diff --git a/src/views/admin/components/edition/item-edition-form.vue b/src/views/admin/components/edition/item-edition-form.vue index b028fa340..1f82e7559 100644 --- a/src/views/admin/components/edition/item-edition-form.vue +++ b/src/views/admin/components/edition/item-edition-form.vue @@ -1320,7 +1320,7 @@ export default { this.isLoading = false; - if (!this.$adminOptions.itemEditionMode) { + if (!this.$adminOptions.itemEditionMode && !this.$adminOptions.mobileAppMode) { if (!this.isOnSequenceEdit) { if (this.form.status != 'trash') { @@ -1345,6 +1345,15 @@ export default { item: this.$adminOptions.itemEditionMode ? this.item : null }, tainacan_plugin.admin_url); + + // In Mobile app, we send a message to inform updates + if ( + this.$adminOptions.mobileAppMode && + webkit && + webkit.messageHandlers && + webkit.messageHandlers.cordova_iab + ) + webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify({ 'type': 'item_updated', 'item': this.item })); }) .catch((errors) => { @@ -1366,14 +1375,14 @@ export default { }); }, onDiscard() { - if (!this.$adminOptions.itemEditionMode) + if (!this.$adminOptions.itemEditionMode && !this.$adminOptions.mobileAppMode) this.$router.go(-1); parent.postMessage({ type: 'itemEditionMessage', item: this.$adminOptions.itemEditionMode ? false : null }, - tainacan_plugin.admin_url); + tainacan_plugin.admin_url); }, createNewItem() { diff --git a/src/views/class-tainacan-admin.php b/src/views/class-tainacan-admin.php index 15d20d42d..3b269696c 100644 --- a/src/views/class-tainacan-admin.php +++ b/src/views/class-tainacan-admin.php @@ -76,6 +76,15 @@ class Admin { array( &$this, 'item_submission' ) ); + add_submenu_page( + null, // Mobile app page is not listed in the menu + __('Mobile App', 'tainacan'), + __('Mobile App', 'tainacan'), + 'manage_tainacan', + 'tainacan_mobile_app', + array( &$this, 'mobile_app' ) + ); + add_action( 'load-' . $page_suffix, array( &$this, 'load_admin_page' ) ); add_action( 'load-' . $roles_page_suffix, array( &$this, 'load_roles_page' ) ); add_action( 'load-' . $reports_page_suffix, array( &$this, 'load_reports_page' ) ); @@ -480,5 +489,11 @@ class Admin { $submission->admin_page(); } + public function mobile_app() { + require_once('mobile-app/class-tainacan-mobile-app.php'); + $Mobile_app = new Mobile_App(); + $Mobile_app->admin_page(); + } + } diff --git a/src/views/mobile-app/admin-page.php b/src/views/mobile-app/admin-page.php new file mode 100644 index 000000000..143032c09 --- /dev/null +++ b/src/views/mobile-app/admin-page.php @@ -0,0 +1,5 @@ +
+

+ +

+
\ No newline at end of file diff --git a/src/views/mobile-app/class-tainacan-mobile-app.php b/src/views/mobile-app/class-tainacan-mobile-app.php new file mode 100644 index 000000000..8e971fc55 --- /dev/null +++ b/src/views/mobile-app/class-tainacan-mobile-app.php @@ -0,0 +1,13 @@ +