Migration system added.
Install scripts for database schema and dummy data too.
This commit is contained in:
@@ -11,7 +11,7 @@ interface floorplan{
|
||||
tableLayer: Konva.Layer
|
||||
rooms: room[]
|
||||
tables: floorplan_table[]
|
||||
decorations: decoration[]
|
||||
decorations: floorplan_decoration[]
|
||||
activeTableNumbers: number[]
|
||||
selectedTableNumber: number
|
||||
selectedDecorationId: number
|
||||
@@ -25,7 +25,7 @@ interface floorplan{
|
||||
|
||||
interface floorplan_data{
|
||||
tables: floorplan_table[]
|
||||
decorations: decoration[]
|
||||
decorations: floorplan_decoration[]
|
||||
activeTableNumbers: number[]
|
||||
rooms: room[]
|
||||
reservations:reservation[]
|
||||
@@ -122,7 +122,7 @@ const loadRoom = (roomToLoad: room) => {
|
||||
button.addClass('active')
|
||||
|
||||
const tablesInRoom = Floorplan.tables.filter(table => table.room_id == roomToLoad.id)
|
||||
const decorationsInRoom = Floorplan.decorations.filter(decoration => decoration.decoration_room == roomToLoad.id)
|
||||
const decorationsInRoom = Floorplan.decorations.filter(decoration => decoration.room_id == roomToLoad.id)
|
||||
decorationsInRoom.forEach(decoration => createDecorationShape(decoration, false))
|
||||
tablesInRoom.forEach(createTableShape)
|
||||
if(!isInMode('transfer')) {
|
||||
@@ -469,21 +469,21 @@ const tableDblClicked = (event: Konva.KonvaEventObject<any>) => {
|
||||
|
||||
}
|
||||
|
||||
const createDecorationShape = (decoration:decoration, select?: boolean) => {
|
||||
const createDecorationShape = (decoration:floorplan_decoration, select?: boolean) => {
|
||||
const draggable = isInMode('edit')
|
||||
const decorationShape = new Image()
|
||||
|
||||
decorationShape.onload = () => {
|
||||
const decorationImage = new Konva.Image({
|
||||
id: decoration.id.toString(),
|
||||
x: decoration.decoration_pos_x * Floorplan.visualScale,
|
||||
y: decoration.decoration_pos_y * Floorplan.visualScale,
|
||||
x: decoration.pos_x * Floorplan.visualScale,
|
||||
y: decoration.pos_y * Floorplan.visualScale,
|
||||
image: decorationShape,
|
||||
offsetX: decoration.decoration_width * 0.5 * Floorplan.visualScale,
|
||||
offsetY: decoration.decoration_height * 0.5 * Floorplan.visualScale,
|
||||
rotation: decoration.decoration_rotation,
|
||||
width: decoration.decoration_width * Floorplan.visualScale,
|
||||
height: decoration.decoration_height * Floorplan.visualScale,
|
||||
offsetX: decoration.width * 0.5 * Floorplan.visualScale,
|
||||
offsetY: decoration.height * 0.5 * Floorplan.visualScale,
|
||||
rotation: decoration.rotation,
|
||||
width: decoration.width * Floorplan.visualScale,
|
||||
height: decoration.height * Floorplan.visualScale,
|
||||
draggable: draggable,
|
||||
});
|
||||
|
||||
@@ -500,7 +500,7 @@ const createDecorationShape = (decoration:decoration, select?: boolean) => {
|
||||
}
|
||||
}
|
||||
|
||||
decorationShape.src = '/images/decorations/' + decoration.decoration_image
|
||||
decorationShape.src = '/images/decorations/' + decoration.image
|
||||
}
|
||||
|
||||
const setupDecorationEvents = (decorationShape: Konva.Image) => {
|
||||
@@ -541,22 +541,22 @@ const getDecorationDataById = (id: number) => {
|
||||
const decorationTransformed = (event: Konva.KonvaEventObject<MouseEvent>|Konva.KonvaEventObject<TouchEvent|DragEvent|MouseEvent>) => {
|
||||
let decorationShape = event.currentTarget as Konva.Image
|
||||
const oldDecorationData = getDecorationDataById(Number(decorationShape.id()))
|
||||
const newDecoration: decoration = {
|
||||
const newDecoration: floorplan_decoration = {
|
||||
id: oldDecorationData.id,
|
||||
decoration_room: oldDecorationData.decoration_room,
|
||||
decoration_pos_x: Math.round(decorationShape.x() / Floorplan.visualScale),
|
||||
decoration_pos_y: Math.round(decorationShape.y() / Floorplan.visualScale),
|
||||
decoration_rotation: Math.round(decorationShape.rotation()),
|
||||
decoration_width: Math.round((decorationShape.scaleX() * decorationShape.width()) / Floorplan.visualScale),
|
||||
decoration_height: Math.round((decorationShape.scaleY() * decorationShape.height()) / Floorplan.visualScale),
|
||||
decoration_image: oldDecorationData.decoration_image,
|
||||
room_id: oldDecorationData.room_id,
|
||||
pos_x: Math.round(decorationShape.x() / Floorplan.visualScale),
|
||||
pos_y: Math.round(decorationShape.y() / Floorplan.visualScale),
|
||||
rotation: Math.round(decorationShape.rotation()),
|
||||
width: Math.round((decorationShape.scaleX() * decorationShape.width()) / Floorplan.visualScale),
|
||||
height: Math.round((decorationShape.scaleY() * decorationShape.height()) / Floorplan.visualScale),
|
||||
image: oldDecorationData.image,
|
||||
venue_id: oldDecorationData.venue_id,
|
||||
}
|
||||
|
||||
saveDecoration(newDecoration)
|
||||
}
|
||||
|
||||
const saveDecoration = (decorationToUpdate: decoration) => {
|
||||
const saveDecoration = (decorationToUpdate: floorplan_decoration) => {
|
||||
const decorations =
|
||||
Floorplan
|
||||
.decorations
|
||||
@@ -576,22 +576,22 @@ const hideDecorator = () => $('#decorator').css('display', 'flex').hide()
|
||||
const addDecoration = (e: Event) => {
|
||||
const button = $(e.currentTarget)
|
||||
|
||||
const newDecoration: decoration = {
|
||||
const newDecoration: floorplan_decoration = {
|
||||
id: 0,
|
||||
decoration_room: Floorplan.currentRoom.id,
|
||||
decoration_pos_x: Floorplan.visualScaleBasis / 2,
|
||||
decoration_pos_y: Floorplan.visualScaleBasis / 2,
|
||||
decoration_rotation: 0,
|
||||
decoration_width: 200,
|
||||
decoration_height: 200,
|
||||
decoration_image: button.data('image'),
|
||||
room_id: Floorplan.currentRoom.id,
|
||||
pos_x: Floorplan.visualScaleBasis / 2,
|
||||
pos_y: Floorplan.visualScaleBasis / 2,
|
||||
rotation: 0,
|
||||
width: 200,
|
||||
height: 200,
|
||||
image: button.data('image'),
|
||||
venue_id: Floorplan.currentRoom.venue_id
|
||||
}
|
||||
|
||||
ajax('/floorplan/addDecoration', newDecoration, 'post', decorationAdded, null, null)
|
||||
}
|
||||
|
||||
const decorationAdded = (decoration: decoration) => {
|
||||
const decorationAdded = (decoration: floorplan_decoration) => {
|
||||
Floorplan.decorations.push(decoration)
|
||||
createDecorationShape(decoration, true)
|
||||
|
||||
@@ -604,7 +604,7 @@ const deleteDecoration = () => ajax(
|
||||
getDecorationDataById(Floorplan.selectedDecorationId),
|
||||
'post', decorationDeleted, null, null)
|
||||
|
||||
const decorationDeleted = (deletedDecoration:decoration) => {
|
||||
const decorationDeleted = (deletedDecoration:floorplan_decoration) => {
|
||||
Floorplan.decorations = Floorplan.decorations.filter(decoration => decoration.id != deletedDecoration.id)
|
||||
const decorationShape = Floorplan.stage.findOne(`#${deletedDecoration.id}`)
|
||||
decorationShape.destroy()
|
||||
@@ -616,8 +616,10 @@ const setRoomBackground = (roomToLoad: room) => {
|
||||
const height = Floorplan.floorplanDiv.height()
|
||||
|
||||
if(roomToLoad.background_image) {
|
||||
Floorplan.floorplanDiv.css("background-image", `url(/images/rooms/${roomToLoad?.background_image})`)
|
||||
Floorplan.floorplanDiv.css("background-image", `url(/images/rooms/${roomToLoad.background_image})`)
|
||||
Floorplan.floorplanDiv.css("background-size", `${width}px ${height}px`)
|
||||
} else {
|
||||
Floorplan.floorplanDiv.css("background-image", "none")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ const addItemToOrderBox = (orderItem:orderItem) => {
|
||||
const existingRow = orderBox
|
||||
.find('tr')
|
||||
.filterByData('item', orderItem.item)
|
||||
.filterByData('print_group', orderItem.print_group)
|
||||
.filterByData('print_group', orderItem.print_group_id)
|
||||
.filterByData('cover', orderItem.cover)
|
||||
.last()
|
||||
|
||||
@@ -186,13 +186,13 @@ const addInstructionToOrderBox = (instruction: orderItem) => {
|
||||
|
||||
|
||||
const addNewItem = (item: item, qty = 1) => {
|
||||
const salesCategory = OrderScreen.sales_categories.where('id', item.item_category)
|
||||
const printGroup = OrderScreen.print_group_override ?? OrderScreen.print_groups.where('id', salesCategory.print_group)
|
||||
const salesCategory = OrderScreen.sales_categories.where('id', item.category)
|
||||
const printGroup = OrderScreen.print_group_override ?? OrderScreen.print_groups.where('id', salesCategory.print_group_id)
|
||||
const orderItem : orderItem = {
|
||||
id: OrderScreen.order_item_id_generator.next().value,
|
||||
item: item,
|
||||
qty: qty,
|
||||
print_group: printGroup,
|
||||
print_group_id: printGroup,
|
||||
cover: OrderScreen.selected_cover,
|
||||
}
|
||||
|
||||
@@ -258,17 +258,17 @@ const renderOrderBox = () => {
|
||||
const createOrderRow = (orderItem: orderItem) => {
|
||||
const row = $('.orderBoxTable').EmptyRow()
|
||||
const price = money(orderItem.item.price1)
|
||||
const itemCellText = $('<span/>').text(orderItem.item.item_name)
|
||||
const itemCellText = $('<span/>').text(orderItem.item.name)
|
||||
row
|
||||
.addClass(`${orderItem.item.item_type}Row`)
|
||||
.setColumnValue(lang('qty_header'), orderItem.qty)
|
||||
.setColumnValue(lang('price_header'), price)
|
||||
.setColumnValue(lang('id_header'), orderItem.item.id)
|
||||
.setColumnValue(lang('total_price_header'), price.multiply(orderItem.qty))
|
||||
.setColumnValue(lang('printgroup_header'), orderItem.print_group?.name)
|
||||
.setColumnValue(lang('printgroup_header'), orderItem.print_group_id?.name)
|
||||
.data('order-item-id', orderItem.id)
|
||||
.data('order-item-id', orderItem.id)
|
||||
.data('print_group', orderItem.print_group)
|
||||
.data('print_group', orderItem.print_group_id)
|
||||
.data('cover', orderItem.cover)
|
||||
.data('item', orderItem.item)
|
||||
.find('td.itemCell')
|
||||
@@ -319,17 +319,17 @@ const gridHtmlGenerated = (gridData: {gridHtml:string, grid: grid}) => {
|
||||
|
||||
gridContainer
|
||||
.show()
|
||||
.width(gridCellWidth * grid.grid_cols)
|
||||
.width(gridCellWidth * grid.cols)
|
||||
.children('.gridContainerHeader')
|
||||
.children('span')
|
||||
.text(grid.grid_name)
|
||||
.text(grid.name)
|
||||
.parent()
|
||||
.parent()
|
||||
.find('.pageGroup')
|
||||
.html(gridHtml)
|
||||
.show()
|
||||
.parent()
|
||||
.height(gridCellHeight * grid.grid_rows)
|
||||
.height(gridCellHeight * grid.rows)
|
||||
.closest('.gridContainer')
|
||||
.find('.pageNavigation')
|
||||
.toggle(gridContainer.find('.gridPage').length > 1)
|
||||
@@ -495,7 +495,7 @@ const freetextSubmitted = (text: string) => {
|
||||
|
||||
const item = Object.assign({}, OrderScreen.custom_item)
|
||||
item.item_type = 'instruction'
|
||||
item.item_name = text
|
||||
item.name = text
|
||||
|
||||
addNewItem(item)
|
||||
|
||||
@@ -509,7 +509,7 @@ const customItemTextSubmitted = (text: string) => {
|
||||
|
||||
const item = Object.assign({}, OrderScreen.custom_item)
|
||||
item.item_type = 'item'
|
||||
item.item_name = text
|
||||
item.name = text
|
||||
item.price1 = price.intValue
|
||||
|
||||
addNewItem(item)
|
||||
|
||||
@@ -10,7 +10,7 @@ interface order {
|
||||
interface orderItem {
|
||||
id: number
|
||||
qty: number
|
||||
print_group: print_group
|
||||
print_group_id: print_group
|
||||
item: item
|
||||
cover: number
|
||||
}
|
||||
@@ -18,7 +18,7 @@ interface orderItem {
|
||||
interface print_group {
|
||||
id: number,
|
||||
name: string,
|
||||
printer: number,
|
||||
printer_id: number,
|
||||
venue_id: number,
|
||||
}
|
||||
|
||||
@@ -50,21 +50,21 @@ interface floorplan_table {
|
||||
id: number
|
||||
}
|
||||
|
||||
interface decoration {
|
||||
interface floorplan_decoration {
|
||||
id: number
|
||||
decoration_room: number
|
||||
decoration_pos_x: number
|
||||
decoration_pos_y: number
|
||||
decoration_rotation: number
|
||||
decoration_width: number
|
||||
decoration_height: number
|
||||
decoration_image: string
|
||||
room_id: number
|
||||
pos_x: number
|
||||
pos_y: number
|
||||
rotation: number
|
||||
width: number
|
||||
height: number
|
||||
image: string
|
||||
venue_id: number
|
||||
}
|
||||
|
||||
interface room {
|
||||
id: number
|
||||
room_name: string
|
||||
name: string
|
||||
background_image: string
|
||||
venue_id: number
|
||||
}
|
||||
@@ -87,26 +87,22 @@ interface keyboard {
|
||||
}
|
||||
|
||||
interface order_screen_page{id: number; order_screen_page_group_id: number; grid_id: number}
|
||||
interface grid {id: number; grid_name: string; grid_rows: number; grid_cols: number; grid_data: string}
|
||||
interface grid {id: number; name: string; rows: number; cols: number; data: string}
|
||||
|
||||
interface item {
|
||||
id: number
|
||||
item_code: string
|
||||
item_category: number
|
||||
item_name: string
|
||||
code: string
|
||||
category: number
|
||||
name: string
|
||||
item_type: string
|
||||
price1: number
|
||||
price2: number
|
||||
price3: number
|
||||
price4: number
|
||||
price5: number
|
||||
}
|
||||
|
||||
type sales_category = {
|
||||
id: number
|
||||
parent: number
|
||||
name: string
|
||||
print_group: string
|
||||
print_group_id: string
|
||||
venue_id: number
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user