cosmetics

This commit is contained in:
Daniel
2020-03-22 22:11:37 +01:00
parent 9998997a73
commit d5db52264a
3 changed files with 35 additions and 21 deletions

View File

@@ -31,24 +31,5 @@
</div>
</body>
<script>
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
},
}})
books.fetch()
</script>
<script src="vue.js"></script>
</html>

32
bookshop/app/vue.js Normal file
View File

@@ -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()

View File

@@ -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;