From ff616b884570abda9279dbf01d65587c030b9b0d Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Thu, 23 Aug 2018 12:22:20 +0530 Subject: [PATCH] [hub][vue] init item card container in vue --- erpnext/public/js/hub/App.vue | 34 +++++++++++ erpnext/public/js/hub/components/ItemCard.vue | 42 ++++++++++++++ .../js/hub/components/ItemCardsContainer.vue | 30 ++++++++++ .../public/js/hub/components/PublishPage.vue | 58 +++++++++++++++++++ .../js/hub/components/publishing_area.js | 1 + erpnext/public/js/hub/pages/publish.js | 38 +++++++----- erpnext/public/js/hub/pages/subpage.js | 5 +- 7 files changed, 191 insertions(+), 17 deletions(-) create mode 100644 erpnext/public/js/hub/App.vue create mode 100644 erpnext/public/js/hub/components/ItemCard.vue create mode 100644 erpnext/public/js/hub/components/ItemCardsContainer.vue create mode 100644 erpnext/public/js/hub/components/PublishPage.vue diff --git a/erpnext/public/js/hub/App.vue b/erpnext/public/js/hub/App.vue new file mode 100644 index 0000000000..37ec4f343a --- /dev/null +++ b/erpnext/public/js/hub/App.vue @@ -0,0 +1,34 @@ + + + + + diff --git a/erpnext/public/js/hub/components/ItemCard.vue b/erpnext/public/js/hub/components/ItemCard.vue new file mode 100644 index 0000000000..7a7f821680 --- /dev/null +++ b/erpnext/public/js/hub/components/ItemCard.vue @@ -0,0 +1,42 @@ + + + + + diff --git a/erpnext/public/js/hub/components/ItemCardsContainer.vue b/erpnext/public/js/hub/components/ItemCardsContainer.vue new file mode 100644 index 0000000000..8014296fb1 --- /dev/null +++ b/erpnext/public/js/hub/components/ItemCardsContainer.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/erpnext/public/js/hub/components/PublishPage.vue b/erpnext/public/js/hub/components/PublishPage.vue new file mode 100644 index 0000000000..06241d6bb3 --- /dev/null +++ b/erpnext/public/js/hub/components/PublishPage.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/erpnext/public/js/hub/components/publishing_area.js b/erpnext/public/js/hub/components/publishing_area.js index 4775c3b16e..c19bf6bb00 100644 --- a/erpnext/public/js/hub/components/publishing_area.js +++ b/erpnext/public/js/hub/components/publishing_area.js @@ -17,6 +17,7 @@ function get_publishing_header() { ${title_html} ${publish_button_html} +

${__('No Items Selected')}

diff --git a/erpnext/public/js/hub/pages/publish.js b/erpnext/public/js/hub/pages/publish.js index f49365833e..d94a755feb 100644 --- a/erpnext/public/js/hub/pages/publish.js +++ b/erpnext/public/js/hub/pages/publish.js @@ -4,29 +4,35 @@ import { get_local_item_card_html } from '../components/item_card'; import { make_search_bar } from '../components/search_bar'; import { get_publishing_header } from '../components/publishing_area'; import { ItemPublishDialog } from '../components/item_publish_dialog'; +import PublishPage from '../components/PublishPage.vue'; -erpnext.hub.Publish = class Publish extends SubPage { - make_wrapper() { - super.make_wrapper(); +erpnext.hub.Publish = class Publish { + constructor(parent) { this.items_data_to_publish = {}; this.unpublished_items = []; this.fetched_items = []; this.fetched_items_dict = {}; - frappe.realtime.on("items-sync", (data) => { - this.$wrapper.find('.progress-bar').css('width', data.progress_percent+'%'); + this.$wrapper = $(`
`).appendTo($(parent)); - if(data.progress_percent === 100 || data.progress_percent === '100') { - setTimeout(() => { - hub.settings.sync_in_progress = 0; - frappe.db.get_doc('Hub Settings') - .then(doc => { - hub.settings = doc; - this.refresh(); - }); - }, 500); - } - }); + frappe.app = new Vue({ + render: h => h(PublishPage), + mounted() { + console.log('Mounted For Publish page'); + }, + }).$mount('#vue-area'); + } + + show() { + this.$wrapper.show(); + } + + hide() { + this.$wrapper.hide(); + } + + show_message(message) { + this.$wrapper.prepend(NotificationMessage(message)); } refresh() { diff --git a/erpnext/public/js/hub/pages/subpage.js b/erpnext/public/js/hub/pages/subpage.js index c8334462cc..cded17985f 100644 --- a/erpnext/public/js/hub/pages/subpage.js +++ b/erpnext/public/js/hub/pages/subpage.js @@ -28,7 +28,10 @@ export default class SubPage { make_wrapper() { const page_name = frappe.get_route()[1]; - this.$wrapper = $(`
`).appendTo(this.$parent); + this.$wrapper = $(`
` + ).appendTo(this.$parent); + this.hide(); }