From fad0f64c94cc7878bd45fd8e71cf8d92b802ea7a Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Sun, 26 Aug 2018 18:27:04 +0530 Subject: [PATCH] [hub][vue] add action object in empty state, make NotFound page --- .../public/js/hub/components/EmptyState.vue | 9 +++- .../public/js/hub/components/empty_state.js | 10 ----- erpnext/public/js/hub/marketplace.js | 22 +++++++++- erpnext/public/js/hub/pages/NotFound.vue | 41 +++++++++++++++++++ erpnext/public/js/hub/pages/messages.js | 8 ++-- erpnext/public/js/hub/pages/not_found.js | 11 ----- 6 files changed, 73 insertions(+), 28 deletions(-) delete mode 100644 erpnext/public/js/hub/components/empty_state.js create mode 100644 erpnext/public/js/hub/pages/NotFound.vue delete mode 100644 erpnext/public/js/hub/pages/not_found.js diff --git a/erpnext/public/js/hub/components/EmptyState.vue b/erpnext/public/js/hub/components/EmptyState.vue index c0ad971aa7..3d35efc797 100644 --- a/erpnext/public/js/hub/components/EmptyState.vue +++ b/erpnext/public/js/hub/components/EmptyState.vue @@ -4,6 +4,13 @@ :style="{ height: height + 'px' }" >

{{ message }}

+

+ +

@@ -15,7 +22,7 @@ export default { message: String, bordered: Boolean, height: Number, - // action: Function + action: Object } } diff --git a/erpnext/public/js/hub/components/empty_state.js b/erpnext/public/js/hub/components/empty_state.js deleted file mode 100644 index 0e1ad46d2f..0000000000 --- a/erpnext/public/js/hub/components/empty_state.js +++ /dev/null @@ -1,10 +0,0 @@ -function get_empty_state(message, action) { - return `
-

${message}

- ${action ? `

${action}

`: ''} -
`; -} - -export { - get_empty_state -} diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js index c61814d0c6..00b6aeea0b 100644 --- a/erpnext/public/js/hub/marketplace.js +++ b/erpnext/public/js/hub/marketplace.js @@ -4,7 +4,6 @@ import Vue from 'vue/dist/vue.js'; import './pages/item'; import './pages/messages'; import './pages/buying_messages'; -import './pages/not_found'; import PageContainer from './PageContainer.vue'; import Home from './pages/Home.vue'; @@ -15,6 +14,7 @@ import Search from './pages/Search.vue'; import PublishedProducts from './pages/PublishedProducts.vue'; import Profile from './pages/Profile.vue'; import Seller from './pages/Seller.vue'; +import NotFound from './pages/NotFound.vue'; // components import { ProfileDialog } from './components/profile_dialog'; @@ -243,7 +243,7 @@ erpnext.hub.Marketplace = class Marketplace { if (!Object.keys(this.subpages).includes(route[1])) { if (!this.subpages.not_found) { - this.subpages.not_found = new erpnext.hub.NotFound(this.$body); + this.subpages.not_found = new erpnext.hub.NotFoundPage(this.$body); } route[1] = 'not_found'; } @@ -423,3 +423,21 @@ erpnext.hub.SellerPage = class { } } +erpnext.hub.NotFoundPage = class { + constructor(parent) { + this.$wrapper = $(`
`).appendTo($(parent)); + + new Vue({ + render: h => h(NotFound) + }).$mount('#vue-area-not-found'); + } + + show() { + $('[data-page-name="not-found"]').show(); + } + + hide() { + $('[data-page-name="not-found"]').hide(); + } +} + diff --git a/erpnext/public/js/hub/pages/NotFound.vue b/erpnext/public/js/hub/pages/NotFound.vue new file mode 100644 index 0000000000..7a76437cfd --- /dev/null +++ b/erpnext/public/js/hub/pages/NotFound.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/erpnext/public/js/hub/pages/messages.js b/erpnext/public/js/hub/pages/messages.js index f8faa99934..6222f53648 100644 --- a/erpnext/public/js/hub/pages/messages.js +++ b/erpnext/public/js/hub/pages/messages.js @@ -1,5 +1,5 @@ import SubPage from './subpage'; -import { get_item_card_container_html } from '../components/items_container'; +// import { get_item_card_container_html } from '../components/items_container'; import { get_buying_item_message_card_html } from '../components/item_card'; import { get_selling_item_message_card_html } from '../components/item_card'; import { get_empty_state } from '../components/empty_state'; @@ -22,7 +22,7 @@ erpnext.hub.Buying = class Buying extends SubPage { } render(items = [], title) { - const html = get_item_card_container_html(items, title, get_buying_item_message_card_html); + // const html = get_item_card_container_html(items, title, get_buying_item_message_card_html); this.$wrapper.append(html); } @@ -54,7 +54,7 @@ erpnext.hub.Selling = class Selling extends SubPage { } render(items = [], title) { - const html = get_item_card_container_html(items, title, get_selling_item_message_card_html); + // const html = get_item_card_container_html(items, title, get_selling_item_message_card_html); this.$wrapper.append(html); } @@ -101,4 +101,4 @@ function get_message_html(message) {

${message.content}

`; -} \ No newline at end of file +} diff --git a/erpnext/public/js/hub/pages/not_found.js b/erpnext/public/js/hub/pages/not_found.js deleted file mode 100644 index f7ccc2f5b3..0000000000 --- a/erpnext/public/js/hub/pages/not_found.js +++ /dev/null @@ -1,11 +0,0 @@ -import SubPage from './subpage'; -import { get_empty_state } from '../components/empty_state'; - -erpnext.hub.NotFound = class NotFound extends SubPage { - refresh() { - this.$wrapper.html(get_empty_state( - __('Sorry! I could not find what you were looking for.'), - `` - )); - } -}