From d5db52264a7899364b37135fc5b0e2842040399c Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 22 Mar 2020 22:11:37 +0100 Subject: [PATCH] cosmetics --- bookshop/app/vue.html | 21 +-------------------- bookshop/app/vue.js | 32 ++++++++++++++++++++++++++++++++ bookshop/db/schema.cds | 3 ++- 3 files changed, 35 insertions(+), 21 deletions(-) create mode 100644 bookshop/app/vue.js diff --git a/bookshop/app/vue.html b/bookshop/app/vue.html index 0a9c4574..eac30b5e 100644 --- a/bookshop/app/vue.html +++ b/bookshop/app/vue.html @@ -31,24 +31,5 @@ - - + diff --git a/bookshop/app/vue.js b/bookshop/app/vue.js new file mode 100644 index 00000000..adc0a288 --- /dev/null +++ b/bookshop/app/vue.js @@ -0,0 +1,32 @@ +/* global Vue axios */ //> from vue.html +const GET = (url) => axios.get('/browse'+url) + +const books = new Vue ({ + + el:'#app', + + data: { + list: [], + info: '( click on a row to see details... )', + }, + + methods: { + + search: ({target:{value:v}}) => books.fetch (v && '$search='+v), + + async fetch (_filter='') { + const columns = 'ID,title,author,price', details = 'genre,currency' + const {data} = await GET(`/Books?$select=${columns}&$expand=${details}&${_filter}`) + books.list = data.value + }, + + async inspect ({currentTarget:{id}}) { + const {data} = await GET(`/Books/${id}?$select=descr`) + books.info = data.descr + }, + + } +}) + +// initilly fill list of books +books.fetch() diff --git a/bookshop/db/schema.cds b/bookshop/db/schema.cds index e7f5872e..8cfefb2b 100644 --- a/bookshop/db/schema.cds +++ b/bookshop/db/schema.cds @@ -1,5 +1,5 @@ -namespace sap.capire.bookshop; using { Currency, managed, sap } from '@sap/cds/common'; +namespace sap.capire.bookshop; entity Books : managed { key ID : Integer; @@ -22,6 +22,7 @@ entity Authors : managed { books : Association to many Books on books.author = $self; } +/** Hierarchically organized Code List for Genres */ entity Genres : sap.common.CodeList { key ID : Integer; parent : Association to Genres;