Merge branch 'master' into cds.context
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
},
|
||||
"rules": {
|
||||
"no-console": "off",
|
||||
"require-atomic-updates": "off"
|
||||
"require-atomic-updates": "off",
|
||||
"require-await":"warn"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using { sap.capire.bookshop as my } from '../db/schema';
|
||||
service CatalogService @(path:'/browse') {
|
||||
|
||||
@readonly entity Books as SELECT from my.Books {*,
|
||||
@readonly entity Books as SELECT from my.Books { *,
|
||||
author.name as author
|
||||
} excluding { createdBy, modifiedBy };
|
||||
|
||||
@readonly entity ListOfBooks as SELECT from Books
|
||||
excluding { descr, stock };
|
||||
excluding { descr };
|
||||
|
||||
@requires: 'authenticated-user'
|
||||
action submitOrder ( book: Books:ID, amount: Integer ) returns { stock: Integer };
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"name": "@capire/common",
|
||||
"version": "1.0.0"
|
||||
"description": "Provides a pre-built extension package for std @sap/cds/common",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@sap/cds": "latest"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ module.exports = async()=>{ // called by server.js
|
||||
//
|
||||
// Reduce stock of ordered books for orders are created from Orders admin UI
|
||||
//
|
||||
OrdersService.on ('OrderChanged', async (msg) => {
|
||||
OrdersService.on ('OrderChanged', (msg) => {
|
||||
console.debug ('> received:', msg.event, msg.data)
|
||||
const { product, deltaAmount } = msg.data
|
||||
return UPDATE (Books) .where ('ID =', product)
|
||||
|
||||
@@ -16,7 +16,7 @@ class OrdersService extends cds.ApplicationService {
|
||||
this.before ('DELETE', 'Orders', async function(req) {
|
||||
const { ID } = req.data
|
||||
const Items = await SELECT.from (OrderItems, oi => { oi.product_ID, oi.amount }) .where ({up__ID:ID})
|
||||
if (Items) for (let it of Items) this.orderChanged (it.product_ID, -it.amount)
|
||||
if (Items) await Promise.all (Items.map(it => this.orderChanged (it.product_ID, -it.amount)))
|
||||
})
|
||||
|
||||
return super.init()
|
||||
|
||||
@@ -37,7 +37,7 @@ const reviews = new Vue ({
|
||||
reviews.message = {}
|
||||
},
|
||||
|
||||
async newReview () {
|
||||
newReview () {
|
||||
reviews.review = {}
|
||||
reviews.message = {}
|
||||
setTimeout (()=> $('form > input').focus(), 111)
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = cds.service.impl (function(){
|
||||
const {subject} = req.data
|
||||
const {rating} = await SELECT.one (['round(avg(rating),2) as rating']) .from (Reviews) .where ({subject})
|
||||
global.it || console.log ('< emitting:', 'reviewed', { subject, rating })
|
||||
this.emit ('reviewed', { subject, rating })
|
||||
await this.emit ('reviewed', { subject, rating })
|
||||
})
|
||||
|
||||
// Increment counter for reviews considered helpful
|
||||
|
||||
Reference in New Issue
Block a user