Updates
This commit is contained in:
1 parent
83b4879743
commit
4d5f1b77b6
17 files changed
+2
-1041
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Auto detect text files and perform LF normalization
|
# Auto detect text files and perform LF normalization
|
||||||
* text=auto
|
* text=auto
|
||||||
/wwwroot/scripts/js/external/* linguist-vendored
|
/wwwroot/scripts/external/* linguist-vendored
|
||||||
/wwwroot/stylesheets/css/* linguist-vendored
|
/wwwroot/stylesheets/css/* linguist-vendored
|
||||||
|
|
||||||
@@ -63,6 +63,7 @@
|
|||||||
<Content Include="xslt\orderHtmltoXML.xslt" />
|
<Content Include="xslt\orderHtmltoXML.xslt" />
|
||||||
<Content Include="xslt\htmlToEscPos.xslt" />
|
<Content Include="xslt\htmlToEscPos.xslt" />
|
||||||
<Content Include=".gitignore" />
|
<Content Include=".gitignore" />
|
||||||
|
<Folder Include="wwwroot\scripts\js" />
|
||||||
<Folder Include="wwwroot\styles\css" />
|
<Folder Include="wwwroot\styles\css" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,13 +0,0 @@
|
|||||||
let showLoginBox = () => showVirtualNumpad('Enter Login Code', 6, true, false, false, authenticate);
|
|
||||||
let authenticate = (input) => {
|
|
||||||
let login = ajaxSync('/ajax/authenticateClerk', input);
|
|
||||||
if (login === 'success') {
|
|
||||||
location.assign('/floorplan');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
showLoginBox();
|
|
||||||
};
|
|
||||||
$(() => {
|
|
||||||
showLoginBox();
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=dredgepos.authenticate.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"dredgepos.authenticate.js","sourceRoot":"","sources":["../ts/dredgepos.authenticate.ts"],"names":[],"mappings":"AAAA,IAAI,YAAY,GAAG,GAAG,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,CAAA;AAEnG,IAAK,YAAY,GAAG,CAAC,KAAc,EAAE,EAAE;IACnC,IAAI,KAAK,GAAG,QAAQ,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAA;IACtD,IAAG,KAAK,KAAK,SAAS,EAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;KAChC;;QAEG,YAAY,EAAE,CAAA;AACtB,CAAC,CAAA;AAED,CAAC,CAAC,GAAG,EAAE;IACH,YAAY,EAAE,CAAA;AAClB,CAAC,CAAC,CAAA"}
|
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
let Application = {
|
|
||||||
keyboard: null,
|
|
||||||
mode: [],
|
|
||||||
languageVars: {}
|
|
||||||
};
|
|
||||||
/** Parses a language variable. */
|
|
||||||
let lang = (key, replacements) => {
|
|
||||||
let finalValue = Application.languageVars[key] || '';
|
|
||||||
if (!replacements)
|
|
||||||
return finalValue;
|
|
||||||
if (typeof replacements === 'string')
|
|
||||||
replacements = [replacements];
|
|
||||||
replacements.forEach((replacement, index) => {
|
|
||||||
let correctIndex = index + 1;
|
|
||||||
finalValue = finalValue.replace(`[${correctIndex}]`, replacement);
|
|
||||||
});
|
|
||||||
return finalValue;
|
|
||||||
};
|
|
||||||
/** Check if a variable is defined */
|
|
||||||
let defined = (variable) => {
|
|
||||||
return typeof variable !== 'undefined';
|
|
||||||
};
|
|
||||||
/** Call an Ajax function asynchronously */
|
|
||||||
let ajax = (endpoint, data, method = 'POST', successFunction, errorFunction, beforeFunction) => {
|
|
||||||
data = (data == null) ? data : JSON.stringify(data);
|
|
||||||
return $.ajax({
|
|
||||||
url: endpoint,
|
|
||||||
method: method,
|
|
||||||
data: data,
|
|
||||||
success: (response) => {
|
|
||||||
if (successFunction && response.status == 'success')
|
|
||||||
successFunction(JSON.parse(response.data));
|
|
||||||
else if (errorFunction && response.status != 'success') {
|
|
||||||
errorFunction(JSON.parse(response.data));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: (error) => console.log(error.statusCode),
|
|
||||||
beforeSend: beforeFunction
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/*
|
|
||||||
For the flow of the app, synchronous is commonly preferred
|
|
||||||
though trying to keep its usage as low as possible.
|
|
||||||
*/
|
|
||||||
let ajaxSync = (endpoint, data, method = 'POST') => {
|
|
||||||
let response = JSON.parse($.ajax({
|
|
||||||
url: endpoint,
|
|
||||||
method: method,
|
|
||||||
data: JSON.stringify(data),
|
|
||||||
async: false,
|
|
||||||
}).responseText);
|
|
||||||
if (response.data) {
|
|
||||||
response.data = JSON.parse(response.data);
|
|
||||||
return response.data;
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
};
|
|
||||||
/* Redirect to a specific URL */
|
|
||||||
let redirect = (url) => location.assign(url);
|
|
||||||
const resize = () => {
|
|
||||||
$('#pageContainer').height(window.innerHeight + "px");
|
|
||||||
};
|
|
||||||
let setupCore = (languageVars) => {
|
|
||||||
Application.languageVars = languageVars;
|
|
||||||
const doc = $(document);
|
|
||||||
doc.on('click', '#alertNo, #alertOk', hideAlerts);
|
|
||||||
window.addEventListener('resize', resize);
|
|
||||||
resize();
|
|
||||||
setElementVisibilityByMode();
|
|
||||||
};
|
|
||||||
// @ts-ignore
|
|
||||||
let posAlert = (message, title = 'Message') => {
|
|
||||||
let alertBox = $('#alert');
|
|
||||||
alertBox.css('display', 'flex');
|
|
||||||
alertBox.data('value', '');
|
|
||||||
$('#alertHeading').text(title);
|
|
||||||
$('#alertMessage').text(message);
|
|
||||||
$('#alertOk').css('display', 'flex');
|
|
||||||
$('#alertYes').css('display', 'none');
|
|
||||||
$('#alertNo').css('display', 'none');
|
|
||||||
};
|
|
||||||
let confirmation = (message, data, title = 'Confirm', submitFunction = (data) => { hideAlerts(); }) => {
|
|
||||||
let alert = $('#alert');
|
|
||||||
$(document).on('click', '#alert #alertYes', () => {
|
|
||||||
hideAlerts();
|
|
||||||
submitFunction(data);
|
|
||||||
$(document).off('click', '#alert #alertYes');
|
|
||||||
});
|
|
||||||
alert.css('display', 'flex');
|
|
||||||
$('#alertHeading').html(title);
|
|
||||||
$('#alertMessage').html(message);
|
|
||||||
$('#alertOk').css('display', 'none');
|
|
||||||
$('#alertYes').css('display', 'flex');
|
|
||||||
$('#alertNo').css('display', 'flex');
|
|
||||||
};
|
|
||||||
let hideAlerts = () => $('#alert').hide();
|
|
||||||
let turnOnMode = (mode) => {
|
|
||||||
Application.mode.push(mode);
|
|
||||||
setElementVisibilityByMode();
|
|
||||||
};
|
|
||||||
let turnOffMode = (mode) => {
|
|
||||||
Application.mode = Application.mode.filter((value) => value != mode);
|
|
||||||
setElementVisibilityByMode();
|
|
||||||
};
|
|
||||||
let toggleMode = (mode) => {
|
|
||||||
if (!isInMode(mode))
|
|
||||||
turnOnMode(mode);
|
|
||||||
else
|
|
||||||
turnOffMode(mode);
|
|
||||||
};
|
|
||||||
let clearModes = () => { Application.mode = []; };
|
|
||||||
let isInMode = (mode) => Application.mode.includes(mode);
|
|
||||||
let setElementVisibilityByMode = () => {
|
|
||||||
const mode = Application.mode;
|
|
||||||
const elements = $('[data-visible-in-mode]');
|
|
||||||
elements.each((index, elem) => {
|
|
||||||
let element = $(elem);
|
|
||||||
let visibleInModes = element.data('visible-in-mode');
|
|
||||||
let showElement = visibleInModes.every(visibleMode => {
|
|
||||||
return mode.includes(visibleMode);
|
|
||||||
});
|
|
||||||
if (element.hasClass('useVisibility')) {
|
|
||||||
if (showElement) {
|
|
||||||
element.css('visibility', 'visible');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
element.css('visibility', 'hidden');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
element.toggle(showElement);
|
|
||||||
});
|
|
||||||
const invisibleElements = $('[data-invisible-in-mode]');
|
|
||||||
invisibleElements.each((index, elem) => {
|
|
||||||
let element = $(elem);
|
|
||||||
let inVisibleInModes = element.data('invisible-in-mode');
|
|
||||||
let hideElement = inVisibleInModes.some(invisibleMode => {
|
|
||||||
return mode.includes(invisibleMode);
|
|
||||||
});
|
|
||||||
element.toggle(!hideElement);
|
|
||||||
});
|
|
||||||
$('[data-active-in-mode]').each((index, elem) => {
|
|
||||||
const button = $(elem);
|
|
||||||
const activeInMode = button.data('active-in-mode');
|
|
||||||
mode.includes(activeInMode)
|
|
||||||
? button.addClass('active')
|
|
||||||
: button.removeClass('active');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
$(() => ajax('/ajax/languageVars', null, 'GET', setupCore, null, null));
|
|
||||||
//# sourceMappingURL=dredgepos.core.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"dredgepos.core.js","sourceRoot":"","sources":["../ts/dredgepos.core.ts"],"names":[],"mappings":"AAAK,IAAI,WAAW,GAAsB;IAClC,QAAQ,EAAG,IAAI;IACf,IAAI,EAAE,EAAE;IACR,YAAY,EAAE,EAAE;CACnB,CAAA;AAGD,kCAAkC;AACjC,IAAI,IAAI,GAAG,CAAC,GAAW,EAAE,YAAgC,EAAE,EAAE;IAC1D,IAAI,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IAEpD,IAAG,CAAC,YAAY;QAAE,OAAO,UAAU,CAAA;IACnC,IAAG,OAAO,YAAY,KAAK,QAAQ;QAAE,YAAY,GAAG,CAAC,YAAY,CAAC,CAAA;IAElE,YAAY,CAAC,OAAO,CAAE,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE;QACzC,IAAI,YAAY,GAAG,KAAK,GAAC,CAAC,CAAA;QAC1B,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,YAAY,GAAG,EAAE,WAAW,CAAC,CAAA;IACrE,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAA;AACrB,CAAC,CAAA;AAED,qCAAqC;AACpC,IAAI,OAAO,GAAG,CAAC,QAAa,EAAE,EAAE;IAC7B,OAAO,OAAO,QAAQ,KAAK,WAA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CAAC,WAAW,CAAC,CAAA;QACrC,CAAC,CAAC,CAAC;QAEH,IAAG,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAC;YACjC,IAAG,WAAW,EAAE;gBACb,OAAO,CAAC,GALine truncated
|
|
||||||
@@ -1,645 +0,0 @@
|
|||||||
/// <reference path="./typings/konva.d.ts" />
|
|
||||||
const Floorplan = {
|
|
||||||
rooms: [],
|
|
||||||
tables: [],
|
|
||||||
decorations: [],
|
|
||||||
reservations: [],
|
|
||||||
activeTableNumbers: [],
|
|
||||||
stage: null,
|
|
||||||
transformer: null,
|
|
||||||
tableLayer: null,
|
|
||||||
selectedTableNumber: 0,
|
|
||||||
currentRoom: null,
|
|
||||||
roomToLoad: null,
|
|
||||||
visualScale: 1,
|
|
||||||
visualScaleBasis: 1280,
|
|
||||||
floorplanDiv: null,
|
|
||||||
selectedDecorationId: 0
|
|
||||||
};
|
|
||||||
$(() => ajax('/ajax/getFloorplanData/1', null, 'get', setupFloorplan, null, null));
|
|
||||||
const setupFloorplanEvents = () => {
|
|
||||||
const doc = $(document);
|
|
||||||
doc.on('click', '.roomButton', roomButtonClicked);
|
|
||||||
doc.on('click', '.editModeButton', editModeButtonClicked);
|
|
||||||
doc.on('click', '.changeShapeButton', changeTableShape);
|
|
||||||
doc.on('click', '.addTableButton', showAddTablePopup);
|
|
||||||
doc.on('click', '.deleteTableButton', confirmDeleteTable);
|
|
||||||
doc.on('click', '.addDecoration', showDecorator);
|
|
||||||
doc.on('click', '.deleteDecoration', deleteDecoration);
|
|
||||||
doc.on('click', '.decoratorItem', addDecoration);
|
|
||||||
doc.on('click', '.mergeButton', toggleMergeMode);
|
|
||||||
doc.on('click', '.unmergeButton', unmergeTable);
|
|
||||||
doc.on('click', '.transferTableButton', toggleTransferMode);
|
|
||||||
doc.on('click', '.reserveTableButton', reserveTable);
|
|
||||||
doc.on('click', '.unreserveTableButton', unreserveTable);
|
|
||||||
};
|
|
||||||
const roomButtonClicked = (e) => {
|
|
||||||
const button = $(e.target);
|
|
||||||
const roomId = button.data('value');
|
|
||||||
loadRoom(getRoomById(roomId));
|
|
||||||
};
|
|
||||||
const editModeButtonClicked = (e) => {
|
|
||||||
const button = $(e.target);
|
|
||||||
button.toggleClass('active');
|
|
||||||
toggleMode('edit');
|
|
||||||
if (isInMode('edit')) {
|
|
||||||
Floorplan.stage.find('Group, Image').forEach(table => table.draggable(true));
|
|
||||||
if (isInMode('tableSelected')) {
|
|
||||||
const selectedTableShape = getTableShapeFromTableNumber(Floorplan.selectedTableNumber);
|
|
||||||
selectTable(selectedTableShape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
setTransformerNodes([]);
|
|
||||||
Floorplan.stage.find('Group, Image').forEach(table => table.draggable(false));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const setupFloorplan = (floorplanData) => {
|
|
||||||
Floorplan.tables = floorplanData.tables;
|
|
||||||
Floorplan.activeTableNumbers = floorplanData.activeTableNumbers;
|
|
||||||
Floorplan.rooms = floorplanData.rooms;
|
|
||||||
Floorplan.decorations = floorplanData.decorations;
|
|
||||||
Floorplan.reservations = floorplanData.reservations;
|
|
||||||
getDimensions();
|
|
||||||
setupFloorplanEvents();
|
|
||||||
loadRoom(Floorplan.rooms[0]);
|
|
||||||
};
|
|
||||||
const loadRoom = (roomToLoad) => {
|
|
||||||
setRoomBackground(roomToLoad);
|
|
||||||
setupKonva();
|
|
||||||
$('.roomButton').removeClass('active');
|
|
||||||
let button = $(`.roomButton[data-value=${roomToLoad.id}]`);
|
|
||||||
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);
|
|
||||||
decorationsInRoom.forEach(decoration => createDecorationShape(decoration, false));
|
|
||||||
tablesInRoom.forEach(createTableShape);
|
|
||||||
if (!isInMode('transfer')) {
|
|
||||||
deselectTables();
|
|
||||||
}
|
|
||||||
Floorplan.currentRoom = roomToLoad;
|
|
||||||
};
|
|
||||||
const getRoomById = (roomId) => {
|
|
||||||
return Floorplan.rooms.find((room) => room.id == roomId);
|
|
||||||
};
|
|
||||||
const tableIsOpen = (table) => Floorplan.activeTableNumbers.includes(table.table_number);
|
|
||||||
const createTableShape = (table) => {
|
|
||||||
const draggable = isInMode('edit');
|
|
||||||
const tableGroup = new Konva.Group({
|
|
||||||
x: table.pos_x * Floorplan.visualScale,
|
|
||||||
y: table.pos_y * Floorplan.visualScale,
|
|
||||||
draggable: draggable,
|
|
||||||
listening: true,
|
|
||||||
id: table.table_number.toString()
|
|
||||||
});
|
|
||||||
const fillColor = tableIsOpen(table)
|
|
||||||
? 'lightblue'
|
|
||||||
: table.status == 2
|
|
||||||
? 'lightgreen'
|
|
||||||
: 'gray';
|
|
||||||
let tableShape;
|
|
||||||
switch (table.shape) {
|
|
||||||
case "circle": // fall-through
|
|
||||||
case "ellipse": // fall-through
|
|
||||||
case "longellipse":
|
|
||||||
tableShape = new Konva.Ellipse({
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
radiusX: table.width * 0.5 * Floorplan.visualScale,
|
|
||||||
radiusY: table.height * 0.5 * Floorplan.visualScale,
|
|
||||||
rotation: table.rotation,
|
|
||||||
fill: fillColor,
|
|
||||||
stroke: "black",
|
|
||||||
strokeWidth: 4,
|
|
||||||
draggable: false,
|
|
||||||
listening: true
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
tableShape = new Konva.Rect({
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
offsetX: table.width * 0.5 * Floorplan.visualScale,
|
|
||||||
offsetY: table.height * 0.5 * Floorplan.visualScale,
|
|
||||||
width: table.width * Floorplan.visualScale,
|
|
||||||
height: table.height * Floorplan.visualScale,
|
|
||||||
rotation: table.rotation,
|
|
||||||
fill: fillColor,
|
|
||||||
stroke: "black",
|
|
||||||
strokeWidth: 4,
|
|
||||||
draggable: false,
|
|
||||||
listening: true
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const label = new Konva.Text({
|
|
||||||
x: table.width * -0.5 * Floorplan.visualScale,
|
|
||||||
y: table.height * -0.5 * Floorplan.visualScale,
|
|
||||||
width: table.width * Floorplan.visualScale,
|
|
||||||
height: table.height * Floorplan.visualScale,
|
|
||||||
text: table.table_number.toString(),
|
|
||||||
fontSize: 40 * Floorplan.visualScale,
|
|
||||||
fill: "black",
|
|
||||||
align: "center",
|
|
||||||
verticalAlign: "middle",
|
|
||||||
draggable: false,
|
|
||||||
listening: false
|
|
||||||
});
|
|
||||||
tableGroup.add(tableShape, label);
|
|
||||||
setupTableEvents(tableGroup);
|
|
||||||
Floorplan.tableLayer.add(tableGroup);
|
|
||||||
return tableGroup;
|
|
||||||
};
|
|
||||||
const setupTableEvents = (tableGroup) => {
|
|
||||||
const tableShape = getTableShapeFromGroup(tableGroup);
|
|
||||||
tableGroup.on('click', tableClicked);
|
|
||||||
tableGroup.on('tap', tableClicked);
|
|
||||||
tableGroup.on('dragend', tableGroupTransformed);
|
|
||||||
tableShape.on('transformend', tableShapeTransformed);
|
|
||||||
};
|
|
||||||
const getTableShapeFromGroup = (group) => group.getChildren()[0];
|
|
||||||
const getTableGroupFromShape = (shape) => shape.parent;
|
|
||||||
const tableGroupTransformed = (e) => {
|
|
||||||
saveTableTransformation(e.target);
|
|
||||||
};
|
|
||||||
const tableShapeTransformed = (e) => {
|
|
||||||
let shape = e.target;
|
|
||||||
let group = getTableGroupFromShape(shape);
|
|
||||||
saveTableTransformation(group);
|
|
||||||
};
|
|
||||||
const saveTableTransformation = (tableGroup) => {
|
|
||||||
const originalTable = getTableDataFromGroup(tableGroup);
|
|
||||||
const tableShape = getTableShapeFromGroup(tableGroup);
|
|
||||||
const newTableInfo = {
|
|
||||||
table_number: originalTable.table_number,
|
|
||||||
previous_state: originalTable.previous_state,
|
|
||||||
merged_children: originalTable.merged_children,
|
|
||||||
id: originalTable.id,
|
|
||||||
width: Math.round(tableShape.scaleX() * tableShape.width() / Floorplan.visualScale),
|
|
||||||
height: Math.round(tableShape.scaleY() * tableShape.height() / Floorplan.visualScale),
|
|
||||||
pos_x: Math.round(tableGroup.x() / Floorplan.visualScale),
|
|
||||||
pos_y: Math.round(tableGroup.y() / Floorplan.visualScale),
|
|
||||||
rotation: Math.round(tableShape.rotation()),
|
|
||||||
room_id: originalTable.room_id,
|
|
||||||
status: originalTable.status,
|
|
||||||
venue_id: originalTable.venue_id,
|
|
||||||
shape: originalTable.shape,
|
|
||||||
default_covers: originalTable.default_covers,
|
|
||||||
};
|
|
||||||
saveTable(newTableInfo);
|
|
||||||
redrawTable(tableGroup);
|
|
||||||
};
|
|
||||||
const saveTable = (tableToUpdate) => {
|
|
||||||
const tables = Floorplan
|
|
||||||
.tables
|
|
||||||
.filter(table => {
|
|
||||||
return table.id != tableToUpdate.id;
|
|
||||||
});
|
|
||||||
tables.push(tableToUpdate);
|
|
||||||
Floorplan.tables = tables;
|
|
||||||
ajax("/ajax/transformTable", tableToUpdate, 'post', null, null, null);
|
|
||||||
};
|
|
||||||
const setTransformerNodes = (nodes) => {
|
|
||||||
Floorplan.transformer.moveToTop();
|
|
||||||
if (nodes.length < 1)
|
|
||||||
Floorplan.transformer.moveToBottom();
|
|
||||||
Floorplan.transformer.nodes(nodes);
|
|
||||||
};
|
|
||||||
const getTableDataFromTableNumber = (tableNumber) => {
|
|
||||||
return Floorplan.tables.filter(table => table.table_number == tableNumber)[0];
|
|
||||||
};
|
|
||||||
const getTableDataFromGroup = (tableGroup) => {
|
|
||||||
const tableNumber = tableGroup.attrs.id;
|
|
||||||
return Floorplan.tables.find(table => tableNumber == table.table_number);
|
|
||||||
};
|
|
||||||
const getTableDataFromShape = (tableShape) => getTableDataFromGroup(tableShape.parent);
|
|
||||||
const getTableShapeFromTableNumber = (tableNumber) => {
|
|
||||||
const tableGroup = Floorplan.stage.find('Group').find((group) => {
|
|
||||||
return group.attrs.id == tableNumber;
|
|
||||||
});
|
|
||||||
return tableGroup.getChildren()[0];
|
|
||||||
};
|
|
||||||
const getTableGroupFromTableNumber = (tableNumber) => {
|
|
||||||
const tableShape = getTableShapeFromTableNumber(tableNumber);
|
|
||||||
return getTableGroupFromShape(tableShape);
|
|
||||||
};
|
|
||||||
const setReservationStatus = (table) => {
|
|
||||||
const reservationText = $('.reservationStatus');
|
|
||||||
const tableShape = getTableShapeFromTableNumber(table.table_number);
|
|
||||||
reservationText.text('');
|
|
||||||
if (table.status == 2) {
|
|
||||||
tableShape.fill('lightgreen');
|
|
||||||
const reservations = Floorplan.reservations.filter(reservation => reservation.reservation_table_id == table.id);
|
|
||||||
if (reservations.length) {
|
|
||||||
turnOnMode('reservedTableSelected');
|
|
||||||
reservationText.text(lang('reserved'));
|
|
||||||
let reservation = reservations[0];
|
|
||||||
if (reservation.reservation_name != '') {
|
|
||||||
reservationText.text(lang('reserved_for', reservation.reservation_name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let fillColor = tableIsOpen(table) ? 'lightblue' : 'gray';
|
|
||||||
tableShape.fill(fillColor);
|
|
||||||
turnOffMode('reservedTableSelected');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const reserveTable = () => {
|
|
||||||
showVirtualNumpad(lang('how_many_covers'), 2, false, false, true, createEmptyReservation);
|
|
||||||
};
|
|
||||||
const createEmptyReservation = (covers) => {
|
|
||||||
const newReservation = {
|
|
||||||
id: 0,
|
|
||||||
reservation_covers: covers,
|
|
||||||
reservation_created_at: 0,
|
|
||||||
reservation_table_id: getSelectedTableData().id,
|
|
||||||
reservation_name: '',
|
|
||||||
reservation_time: 0,
|
|
||||||
};
|
|
||||||
ajax('/ajax/newEmptyReservation', newReservation, 'post', emptyReservationCreated, null, null);
|
|
||||||
};
|
|
||||||
const emptyReservationCreated = (reservation) => {
|
|
||||||
Floorplan.reservations.push(reservation);
|
|
||||||
const selectedTable = getSelectedTableData();
|
|
||||||
selectedTable.status = 2;
|
|
||||||
selectedTable.default_covers = reservation.reservation_covers;
|
|
||||||
updateTableData(selectedTable);
|
|
||||||
updateCoverText(selectedTable);
|
|
||||||
setReservationStatus(getSelectedTableData());
|
|
||||||
showVirtualKeyboard(lang('confirm_reservation_name'), 32, false, addReservationName);
|
|
||||||
};
|
|
||||||
const addReservationName = (name) => {
|
|
||||||
hideVirtualKeyboard();
|
|
||||||
const reservation = Floorplan.reservations.filter(reservation => reservation.reservation_table_id == getSelectedTableData().id)[0];
|
|
||||||
reservation.reservation_name = name;
|
|
||||||
ajax('/ajax/updateReservation', reservation, 'post', reservationNameAdded, null, null);
|
|
||||||
};
|
|
||||||
const reservationNameAdded = (updatedReservation) => {
|
|
||||||
console.log(updatedReservation);
|
|
||||||
Floorplan.reservations = Floorplan.reservations.filter(reservation => reservation.id != updatedReservation.id);
|
|
||||||
Floorplan.reservations.push(updatedReservation);
|
|
||||||
setReservationStatus(getSelectedTableData());
|
|
||||||
};
|
|
||||||
const getReservationsOnTable = (table) => Floorplan.reservations.filter(reservation => reservation.reservation_table_id == table.id);
|
|
||||||
const updateTableData = (tableToRemove) => {
|
|
||||||
Floorplan.tables = Floorplan.tables.filter(table => table.id != tableToRemove.id);
|
|
||||||
Floorplan.tables.push(tableToRemove);
|
|
||||||
};
|
|
||||||
const unreserveTable = () => {
|
|
||||||
const selectedTable = getSelectedTableData();
|
|
||||||
selectedTable.status = 0;
|
|
||||||
ajax('/ajax/unreserveTable', selectedTable, 'post', tableUnreserved, null, null);
|
|
||||||
};
|
|
||||||
const tableUnreserved = (table) => {
|
|
||||||
Floorplan.reservations = Floorplan.reservations.filter(reservation => reservation.reservation_table_id != table.id);
|
|
||||||
updateTableData(table);
|
|
||||||
setReservationStatus(table);
|
|
||||||
};
|
|
||||||
const getSelectedTableData = () => getTableDataFromTableNumber(Floorplan.selectedTableNumber);
|
|
||||||
const deselectTables = () => {
|
|
||||||
Floorplan.stage.find('Rect, Ellipse').forEach((shape, index) => {
|
|
||||||
shape.stroke('black');
|
|
||||||
});
|
|
||||||
Floorplan.selectedDecorationId = 0;
|
|
||||||
Floorplan.selectedTableNumber = 0;
|
|
||||||
turnOffMode('tableSelected');
|
|
||||||
turnOffMode('activeTableSelected');
|
|
||||||
turnOffMode('decorationSelected');
|
|
||||||
turnOffMode('merge');
|
|
||||||
turnOffMode('transfer');
|
|
||||||
setTransformerNodes([]);
|
|
||||||
};
|
|
||||||
const selectTable = (tableShape) => {
|
|
||||||
tableShape.stroke('yellow');
|
|
||||||
const table = getTableDataFromShape(tableShape);
|
|
||||||
Floorplan.selectedTableNumber = table.table_number;
|
|
||||||
if (isInMode('edit')) {
|
|
||||||
setTransformerNodes([tableShape]);
|
|
||||||
}
|
|
||||||
if (tableIsOpen(table)) {
|
|
||||||
turnOnMode('activeTableSelected');
|
|
||||||
}
|
|
||||||
$('.reservationStatus').html('<b>' + lang('active_table', table.table_number.toString() + '</b>'));
|
|
||||||
updateCoverText(table);
|
|
||||||
$('.selectedTableNumber').text(lang('active_table', table.table_number.toString()));
|
|
||||||
setReservationStatus(table);
|
|
||||||
const unmergeVisibility = table.merged_children ? 'visible' : 'hidden';
|
|
||||||
$('.unmergeButton').css('visibility', unmergeVisibility);
|
|
||||||
turnOnMode('tableSelected');
|
|
||||||
};
|
|
||||||
const updateCoverText = (table) => $('.selectedTableCovers').text(lang('covers', table.default_covers.toString()));
|
|
||||||
const tableClicked = (event) => {
|
|
||||||
let tableShape = getTableShapeFromGroup(event.currentTarget);
|
|
||||||
const table = getTableDataFromShape(tableShape);
|
|
||||||
if (isInMode('merge')) {
|
|
||||||
mergeTables(getTableDataFromTableNumber(Floorplan.selectedTableNumber), table);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isInMode('transfer')) {
|
|
||||||
transferTables(getTableDataFromTableNumber(Floorplan.selectedTableNumber), table);
|
|
||||||
}
|
|
||||||
const selectedTableNumber = Floorplan.selectedTableNumber;
|
|
||||||
deselectTables();
|
|
||||||
if (selectedTableNumber != table.table_number) {
|
|
||||||
selectTable(tableShape);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const createDecorationShape = (decoration, select) => {
|
|
||||||
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,
|
|
||||||
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,
|
|
||||||
draggable: draggable,
|
|
||||||
});
|
|
||||||
// add the shape to the layer
|
|
||||||
Floorplan.tableLayer.add(decorationImage);
|
|
||||||
Floorplan.tableLayer.draw();
|
|
||||||
decorationImage.moveToBottom();
|
|
||||||
setupDecorationEvents(decorationImage);
|
|
||||||
if (select) {
|
|
||||||
decorationImage.moveToTop();
|
|
||||||
selectDecorationShape(decorationImage);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
decorationShape.src = 'images/decorations/' + decoration.decoration_image;
|
|
||||||
};
|
|
||||||
const setupDecorationEvents = (decorationShape) => {
|
|
||||||
decorationShape.on('click', decorationClicked);
|
|
||||||
decorationShape.on('tap', decorationClicked);
|
|
||||||
decorationShape.on('transformend', decorationTransformed);
|
|
||||||
decorationShape.on('dragend', decorationTransformed);
|
|
||||||
};
|
|
||||||
const decorationClicked = (event) => {
|
|
||||||
let decorationShape = event.target;
|
|
||||||
if (isInMode('edit')) {
|
|
||||||
turnOffMode('tableSelected');
|
|
||||||
if ((Floorplan.transformer.nodes().length > 0 && Floorplan.transformer.nodes()[0] != decorationShape) || Floorplan.transformer.nodes().length == 0) {
|
|
||||||
selectDecorationShape(decorationShape);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
deselectTables();
|
|
||||||
decorationShape.moveToBottom();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const selectDecorationShape = (decorationShape) => {
|
|
||||||
deselectTables();
|
|
||||||
Floorplan.transformer.nodes([decorationShape]);
|
|
||||||
Floorplan.selectedDecorationId = Number(decorationShape.id());
|
|
||||||
decorationShape.moveToTop();
|
|
||||||
Floorplan.transformer.moveToTop();
|
|
||||||
turnOnMode('decorationSelected');
|
|
||||||
};
|
|
||||||
const getDecorationDataById = (id) => {
|
|
||||||
return Floorplan.decorations.find(decoration => id == decoration.id);
|
|
||||||
};
|
|
||||||
const decorationTransformed = (event) => {
|
|
||||||
let decorationShape = event.currentTarget;
|
|
||||||
const oldDecorationData = getDecorationDataById(Number(decorationShape.id()));
|
|
||||||
const newDecoration = {
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
saveDecoration(newDecoration);
|
|
||||||
};
|
|
||||||
const saveDecoration = (decorationToUpdate) => {
|
|
||||||
const decorations = Floorplan
|
|
||||||
.decorations
|
|
||||||
.filter(decoration => {
|
|
||||||
return decoration.id != decorationToUpdate.id;
|
|
||||||
});
|
|
||||||
decorations.push(decorationToUpdate);
|
|
||||||
Floorplan.decorations = decorations;
|
|
||||||
ajax("/ajax/updateDecoration", decorationToUpdate, 'post', null, null, null);
|
|
||||||
};
|
|
||||||
const showDecorator = () => $('#decorator').css('display', 'flex');
|
|
||||||
const hideDecorator = () => $('#decorator').css('display', 'flex').hide();
|
|
||||||
const addDecoration = (e) => {
|
|
||||||
const button = $(e.currentTarget);
|
|
||||||
const newDecoration = {
|
|
||||||
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')
|
|
||||||
};
|
|
||||||
ajax('/ajax/addDecoration', newDecoration, 'post', decorationAdded, null, null);
|
|
||||||
};
|
|
||||||
const decorationAdded = (decoration) => {
|
|
||||||
Floorplan.decorations.push(decoration);
|
|
||||||
createDecorationShape(decoration, true);
|
|
||||||
hideDecorator();
|
|
||||||
};
|
|
||||||
const deleteDecoration = () => ajax('/ajax/deleteDecoration', getDecorationDataById(Floorplan.selectedDecorationId), 'post', decorationDeleted, null, null);
|
|
||||||
const decorationDeleted = (deletedDecoration) => {
|
|
||||||
Floorplan.decorations = Floorplan.decorations.filter(decoration => decoration.id != deletedDecoration.id);
|
|
||||||
const decorationShape = Floorplan.stage.findOne(`#${deletedDecoration.id}`);
|
|
||||||
decorationShape.destroy();
|
|
||||||
deselectTables();
|
|
||||||
};
|
|
||||||
const setRoomBackground = (roomToLoad) => {
|
|
||||||
const width = Floorplan.floorplanDiv.width();
|
|
||||||
const height = Floorplan.floorplanDiv.height();
|
|
||||||
Floorplan.floorplanDiv.css("background-image", `url(images/rooms/${roomToLoad.background_image})`);
|
|
||||||
Floorplan.floorplanDiv.css("background-size", `${width}px ${height}px`);
|
|
||||||
};
|
|
||||||
const setupKonva = () => {
|
|
||||||
const dimensions = getDimensions();
|
|
||||||
if (Floorplan.stage !== null)
|
|
||||||
Floorplan.stage.destroy();
|
|
||||||
Floorplan.stage = new Konva.Stage({
|
|
||||||
container: 'floorplanCanvas',
|
|
||||||
width: dimensions.width,
|
|
||||||
height: dimensions.height,
|
|
||||||
});
|
|
||||||
Floorplan.stage.on('click', e => {
|
|
||||||
if (e.target == Floorplan.stage) {
|
|
||||||
deselectTables();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Floorplan.transformer = new Konva.Transformer({
|
|
||||||
rotationSnaps: [0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 225, 270, -15, -30, -45, -60, -75, -90, -105, -120, -135, -150, -165, -180, -225, -270, 360, -360],
|
|
||||||
anchorSize: 30 * Floorplan.visualScale,
|
|
||||||
ignoreStroke: true,
|
|
||||||
centeredScaling: true,
|
|
||||||
anchorCornerRadius: 10,
|
|
||||||
});
|
|
||||||
Floorplan.tableLayer = new Konva.Layer();
|
|
||||||
Floorplan.tableLayer.add(Floorplan.transformer);
|
|
||||||
Floorplan.stage.add(Floorplan.tableLayer);
|
|
||||||
};
|
|
||||||
const resetKonva = setupKonva;
|
|
||||||
const changeTableShape = () => {
|
|
||||||
if (!Floorplan.selectedTableNumber)
|
|
||||||
return;
|
|
||||||
const table = getTableDataFromTableNumber(Floorplan.selectedTableNumber);
|
|
||||||
const tableGroup = getTableGroupFromTableNumber(table.table_number);
|
|
||||||
const order = ['square', 'rect', 'longrect', 'diamond', 'circle', 'ellipse', 'longellipse'];
|
|
||||||
if (order.indexOf(table.shape) === -1)
|
|
||||||
table.shape = 'square';
|
|
||||||
const currentIndex = order.indexOf(table.shape);
|
|
||||||
let nextIndex = currentIndex + 1;
|
|
||||||
if (nextIndex > (order.length) - 1)
|
|
||||||
nextIndex = 0;
|
|
||||||
table.shape = order[nextIndex];
|
|
||||||
switch (table.shape) {
|
|
||||||
case 'square':
|
|
||||||
case 'circle':
|
|
||||||
// noinspection JSSuspiciousNameCombination
|
|
||||||
table.height = table.width;
|
|
||||||
table.rotation = 0;
|
|
||||||
break;
|
|
||||||
case 'diamond':
|
|
||||||
// noinspection JSSuspiciousNameCombination
|
|
||||||
table.height = table.width;
|
|
||||||
table.rotation = 45;
|
|
||||||
break;
|
|
||||||
case 'rect':
|
|
||||||
case 'ellipse':
|
|
||||||
table.height = table.width * 2;
|
|
||||||
table.rotation = 0;
|
|
||||||
break;
|
|
||||||
case 'longrect':
|
|
||||||
case 'longellipse':
|
|
||||||
table.rotation = 90;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
saveTable(table);
|
|
||||||
deselectTables();
|
|
||||||
redrawTable(tableGroup);
|
|
||||||
};
|
|
||||||
const redrawTable = (tableGroup) => {
|
|
||||||
deselectTables();
|
|
||||||
const draggable = tableGroup.draggable();
|
|
||||||
const table = getTableDataFromGroup(tableGroup);
|
|
||||||
tableGroup.destroy();
|
|
||||||
const newTableGroup = createTableShape(table);
|
|
||||||
const newTableShape = getTableShapeFromTableNumber(table.table_number);
|
|
||||||
selectTable(newTableShape);
|
|
||||||
newTableGroup.draggable(draggable);
|
|
||||||
};
|
|
||||||
const showAddTablePopup = () => showVirtualNumpad(lang('new_table_number'), 4, false, false, true, addTable);
|
|
||||||
const addTable = (tableNumber) => {
|
|
||||||
const newTable = {
|
|
||||||
id: 0,
|
|
||||||
table_number: tableNumber,
|
|
||||||
room_id: Floorplan.currentRoom.id,
|
|
||||||
default_covers: 2,
|
|
||||||
width: 200,
|
|
||||||
height: 200,
|
|
||||||
rotation: 0,
|
|
||||||
pos_x: Floorplan.visualScaleBasis / 2,
|
|
||||||
pos_y: Floorplan.visualScaleBasis / 2,
|
|
||||||
shape: 'square',
|
|
||||||
merged_children: '',
|
|
||||||
previous_state: '',
|
|
||||||
status: 0,
|
|
||||||
venue_id: 1
|
|
||||||
};
|
|
||||||
ajax('/ajax/createTable', newTable, 'post', tableAdded, tableNotAdded, null);
|
|
||||||
};
|
|
||||||
const tableAdded = (table) => {
|
|
||||||
deselectTables();
|
|
||||||
const newTableGroup = createTableShape(table);
|
|
||||||
Floorplan.tables.push(table);
|
|
||||||
selectTable(getTableShapeFromGroup(newTableGroup));
|
|
||||||
};
|
|
||||||
const tableNotAdded = (response) => {
|
|
||||||
posAlert(response);
|
|
||||||
};
|
|
||||||
const confirmDeleteTable = () => confirmation(lang('confirm_delete_table', Floorplan.selectedTableNumber.toString()), Floorplan.selectedTableNumber, 'Confirm', deleteTable);
|
|
||||||
const deleteTable = (tableNumber) => {
|
|
||||||
if (!tableNumber)
|
|
||||||
return false;
|
|
||||||
const tableToDelete = getTableDataFromTableNumber(tableNumber);
|
|
||||||
if (tableIsOpen(tableToDelete)) {
|
|
||||||
posAlert(lang('error_delete_existing_table'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ajax(`/ajax/deleteTable`, tableToDelete, 'post', tableDeleted, null, null);
|
|
||||||
};
|
|
||||||
const tableDeleted = (deletedTable) => {
|
|
||||||
Floorplan.tables = Floorplan.tables.filter(table => table.table_number != deletedTable.table_number);
|
|
||||||
const tableGroup = getTableGroupFromTableNumber(deletedTable.table_number);
|
|
||||||
deselectTables();
|
|
||||||
tableGroup.destroy();
|
|
||||||
};
|
|
||||||
const toggleMergeMode = () => toggleMode('merge');
|
|
||||||
const mergeTables = (table1, table2) => {
|
|
||||||
toggleMergeMode();
|
|
||||||
if (table1.table_number == table2.table_number) {
|
|
||||||
posAlert(lang('error_self_merge'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ajax('/ajax/mergeTables', [table1, table2], 'post', tablesMerged, null, null);
|
|
||||||
};
|
|
||||||
const tablesMerged = (tables) => {
|
|
||||||
tableDeleted(tables['child']);
|
|
||||||
tableDeleted(tables['parent']);
|
|
||||||
tableAdded(tables['merged']);
|
|
||||||
deselectTables();
|
|
||||||
const tableGroup = getTableGroupFromTableNumber(tables['merged'].table_number);
|
|
||||||
selectTable(getTableShapeFromGroup(tableGroup));
|
|
||||||
tableGroup.draggable(true);
|
|
||||||
};
|
|
||||||
const unmergeTable = () => ajax(`/ajax/unmergeTable/${Floorplan.selectedTableNumber}`, null, 'get', tablesUnmerged, null, null);
|
|
||||||
const tablesUnmerged = (tables) => {
|
|
||||||
const parentTable = tables['parent'];
|
|
||||||
const childTable = tables['child'];
|
|
||||||
tableDeleted(parentTable);
|
|
||||||
tableAdded(parentTable);
|
|
||||||
tableAdded(childTable);
|
|
||||||
deselectTables();
|
|
||||||
};
|
|
||||||
const toggleTransferMode = () => toggleMode('transfer');
|
|
||||||
const transferTables = (origin, destination) => {
|
|
||||||
if (origin.table_number == destination.table_number) {
|
|
||||||
posAlert(lang('transfer_self_error'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ajax(`/ajax/transferTable/${origin.table_number}/${destination.table_number}`, null, 'get', tableTransferred, null, null);
|
|
||||||
};
|
|
||||||
const tableTransferred = (tables) => {
|
|
||||||
const origin = tables['origin'];
|
|
||||||
const destination = tables['destination'];
|
|
||||||
Floorplan.activeTableNumbers = Floorplan.activeTableNumbers.filter(tableNumber => tableNumber != origin.table_number);
|
|
||||||
Floorplan.activeTableNumbers.push(destination.table_number);
|
|
||||||
if (Floorplan.currentRoom.id == origin.room_id) {
|
|
||||||
redrawTable(getTableGroupFromTableNumber(origin.table_number));
|
|
||||||
}
|
|
||||||
redrawTable(getTableGroupFromTableNumber(destination.table_number));
|
|
||||||
};
|
|
||||||
const getDimensions = () => {
|
|
||||||
Floorplan.floorplanDiv = $('#floorplanCanvas');
|
|
||||||
const parentDiv = $('#floorplanCenterColumn .middleCell');
|
|
||||||
const outerWidth = parentDiv.outerWidth();
|
|
||||||
const outerHeight = parentDiv.outerHeight();
|
|
||||||
if (outerWidth >= outerHeight) {
|
|
||||||
Floorplan.floorplanDiv.css('height', '100%');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Floorplan.floorplanDiv.css('width', '100%');
|
|
||||||
}
|
|
||||||
Floorplan.visualScale = Floorplan.floorplanDiv.width() / Floorplan.visualScaleBasis;
|
|
||||||
return { width: Floorplan.floorplanDiv.width(), height: Floorplan.floorplanDiv.height() };
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=dredgepos.floorplan.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"dredgepos.floorplan.js","sourceRoot":"","sources":["../ts/dredgepos.floorplan.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAkC7C,MAAM,SAAS,GAAc;IACzB,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;IACV,WAAW,EAAC,EAAE;IACd,YAAY,EAAC,EAAE;IACf,kBAAkB,EAAE,EAAE;IACtB,KAAK,EAAE,IAAI;IACX,WAAW,EAAC,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,mBAAmB,EAAE,CAAC;IACtB,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,CAAC;IACd,gBAAgB,EAAE,IAAI;IACtB,YAAY,EAAE,IAAI;IAClB,oBAAoB,EAAE,CAAC;CAC1B,CAAC;AAEF,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,CAAC,CAAE,CAAA;AAGnF,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAC9B,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAA;IACvB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAA;IACjD,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,CAAC,CAAA;IACzD,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,CAAC,CAAA;IACvD,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAA;IACrD,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,CAAC,CAAA;IACzD,GAAG,CAAC,EAAE,CAAC,OAAO,E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AAG,WAAW,CAAC,KAAK,CAAC;QACpB,CAAC,CAAC,WAAW;QACb,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC;YACf,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,MAAM,CAAA;IAG5B,IAAI,UAAuB,CAAA;IAE3B,QAAO,KAAK,CAAC,KAAK,EAAC;QACf,KAAK,QAAQ,CAAC,CAAC,eAAe;QAC9B,KAAK,SAAS,CAAC,CAAC,eAAe;QAC/B,KAAK,aAAa;YACd,UAAU,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC;gBAC3B,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,CAAC;gBACJ,OAAO,EAAE,KAAK,CAAC,KAAK,GAAG,GAAG,GAAG,SAAS,CAAC,WAAW;gBAClD,OAAO,EAAE,KAAK,CAAC,MAAM,GAAG,GAAG,GAAG,SAAS,CAAC,WAAW;gBACnD,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO;gBACf,WAAW,EAAE,CAAC;gBACd,SAAS,EAAE,KAAK;gBAChB,SAAS,EAAE,IAAI;aAClB,CAAC,CAAC;YACH,MAAM;QACV;YACI,UAAU,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC;gBACxB,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,CAAC;gBACJ,OAAO,EAAE,KAAK,CAAC,KAAK,GAAG,GAAG,GAAG,SAAS,CAAC,WAAW;gBAClD,OAAO,EAAE,KAAK,CAAC,MAAM,GAAG,GAAG,GAAG,SAAS,CAAC,WAAW;gBACnD,KAAK,EAAE,Line truncated
|
|
||||||
@@ -1,224 +0,0 @@
|
|||||||
let showVirtualNumpad = (heading, maxlength = 4, isPassword, allowDecimals = true, allowClose = true, submitFunction) => {
|
|
||||||
let numpad = $('#virtualNumpad');
|
|
||||||
let inputBox = $('#virtualNumpadInput');
|
|
||||||
let closeKeyboardButton = $('.closeKeyboards');
|
|
||||||
numpad.css('display', 'flex');
|
|
||||||
let showCloseButton = allowClose ? 'flex' : 'none';
|
|
||||||
closeKeyboardButton.css('display', showCloseButton);
|
|
||||||
$('#virtualNumpadHeading').html(heading);
|
|
||||||
/*
|
|
||||||
The numpad always submits to a function.
|
|
||||||
If a function isn't specified, it will submit
|
|
||||||
to the same function that called it
|
|
||||||
*/
|
|
||||||
numpad.data('value', '');
|
|
||||||
inputBox.text('');
|
|
||||||
numpad.data('maxlength', maxlength);
|
|
||||||
numpad.data('submitfunction', submitFunction);
|
|
||||||
numpad.data('password', isPassword);
|
|
||||||
numpad.data('allowdecimals', allowDecimals);
|
|
||||||
$(document).off('keyup');
|
|
||||||
$(document).on('keyup', e => {
|
|
||||||
let key = e.key;
|
|
||||||
switch (key) {
|
|
||||||
case 'Backspace':
|
|
||||||
case 'Delete':
|
|
||||||
key = 'clear';
|
|
||||||
break;
|
|
||||||
case 'Enter':
|
|
||||||
key = 'submit';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
virtualNumpadInput(key);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
let hideVirtualKeyboard = () => {
|
|
||||||
let keyboard = $('#virtualKeyboard');
|
|
||||||
keyboard.hide();
|
|
||||||
$('#virtualKeyboardHeading').html('');
|
|
||||||
$(document).unbind('keyup');
|
|
||||||
};
|
|
||||||
let hideVirtualNumpad = () => {
|
|
||||||
let numpad = $('#virtualNumpad');
|
|
||||||
numpad.css('display', 'none');
|
|
||||||
$('#virtualNumpadHeading').html('');
|
|
||||||
$(document).unbind('keyup');
|
|
||||||
};
|
|
||||||
let virtualNumpadInput = (input) => {
|
|
||||||
let inputBox = $('#virtualNumpadInput');
|
|
||||||
let numpad = $('#virtualNumpad');
|
|
||||||
let maxlength = numpad.data('maxlength');
|
|
||||||
let allowDecimals = numpad.data('allowdecimals');
|
|
||||||
let submitFunction = numpad.data('submitfunction');
|
|
||||||
let allowedValues = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'submit', 'clear'];
|
|
||||||
let currentValue = numpad.data('value').toString();
|
|
||||||
if (allowDecimals)
|
|
||||||
allowedValues.push('.', ',');
|
|
||||||
let validInput = allowedValues.includes(input);
|
|
||||||
//If the input is a valid number, decimal point or command.
|
|
||||||
if (validInput) {
|
|
||||||
switch (input) {
|
|
||||||
case 'submit':
|
|
||||||
hideVirtualNumpad();
|
|
||||||
let numpadValue = numpad.data('value').length > 0 ? numpad.data('value') : "0";
|
|
||||||
submitFunction(numpadValue);
|
|
||||||
break;
|
|
||||||
case 'clear':
|
|
||||||
clearNumpadInput();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
let newText = currentValue + input;
|
|
||||||
let isPassword = numpad.data('password');
|
|
||||||
let length = input.length + inputBox.text().length;
|
|
||||||
if (length <= maxlength) {
|
|
||||||
inputBox.append(isPassword ? '*' : input);
|
|
||||||
numpad.data('value', newText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let clearNumpadInput = () => {
|
|
||||||
$('#virtualNumpadInput').text("");
|
|
||||||
$('#virtualNumpad').data('value', '');
|
|
||||||
};
|
|
||||||
let setupVirtualNumpad = () => {
|
|
||||||
$(document).on('click', '.virtualNumpadButton', e => {
|
|
||||||
virtualNumpadInput($(e.target).data('value').toString());
|
|
||||||
});
|
|
||||||
$('.closeKeyboards').on('click', () => {
|
|
||||||
hideVirtualKeyboard();
|
|
||||||
hideVirtualNumpad();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
let setupVirtualKeyboard = (keyboardLayouts) => {
|
|
||||||
Application.keyboard = {
|
|
||||||
capsLock: false,
|
|
||||||
shift: false,
|
|
||||||
layouts: keyboardLayouts,
|
|
||||||
currentLayout: 'default',
|
|
||||||
};
|
|
||||||
$(document).on('click', '.virtualKeyboardButton', e => {
|
|
||||||
virtualKeyboardInput($(e.target).data('value'));
|
|
||||||
});
|
|
||||||
$(document).on('click', '.forceFocus', (e) => {
|
|
||||||
$('#virtualKeyboardInput').trigger('focus');
|
|
||||||
});
|
|
||||||
setKeyboardLayout('default');
|
|
||||||
};
|
|
||||||
let showVirtualKeyboard = (heading, maxlength = 32, isPassword = false, submitFunction = () => { hideVirtualKeyboard(); }) => {
|
|
||||||
let keyboard = $('#virtualKeyboard');
|
|
||||||
let inputBox = $('#virtualKeyboardInput');
|
|
||||||
keyboard.css('display', 'flex');
|
|
||||||
$('#virtualKeyboardHeading').html(heading);
|
|
||||||
$('.forceFocus').trigger('click');
|
|
||||||
keyboard.data('value', '');
|
|
||||||
inputBox.val('');
|
|
||||||
keyboard.data('maxlength', maxlength);
|
|
||||||
keyboard.data('password', isPassword);
|
|
||||||
keyboard.data('submitfunction', submitFunction);
|
|
||||||
inputBox.attr('autofocus', 'autofocus');
|
|
||||||
inputBox.trigger('focus');
|
|
||||||
inputBox.trigger('click');
|
|
||||||
inputBox.trigger('select');
|
|
||||||
$(document).on('keyup', e => {
|
|
||||||
let key = e.key;
|
|
||||||
if (key == 'Enter' && inputBox.val().toString().length > 0) {
|
|
||||||
key = 'submit';
|
|
||||||
virtualKeyboardInput(key);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
let virtualKeyboardInput = (input) => {
|
|
||||||
let inputBox = $('#virtualKeyboardInput');
|
|
||||||
let keyboard = $('#virtualKeyboard');
|
|
||||||
let maxlength = keyboard.data('maxlength');
|
|
||||||
let isPassword = keyboard.data('password');
|
|
||||||
let length = input.length + inputBox.text().length;
|
|
||||||
switch (input.toLowerCase()) {
|
|
||||||
case 'backspace':
|
|
||||||
case 'delete':
|
|
||||||
let newText = inputBox.text().slice(0, -1);
|
|
||||||
inputBox.val(newText);
|
|
||||||
keyboard.data('value', newText);
|
|
||||||
break;
|
|
||||||
case 'submit':
|
|
||||||
hideVirtualKeyboard();
|
|
||||||
let submitFunction = keyboard.data('submitfunction');
|
|
||||||
submitFunction(inputBox.val());
|
|
||||||
break;
|
|
||||||
case 'shift':
|
|
||||||
if (Application.keyboard.capsLock)
|
|
||||||
break;
|
|
||||||
Application.keyboard.shift = !Application.keyboard.shift;
|
|
||||||
Application.keyboard.capsLock = false;
|
|
||||||
setKeyboardLayout('default', Application.keyboard.shift ? 'shift' : '');
|
|
||||||
break;
|
|
||||||
case 'capslock':
|
|
||||||
Application.keyboard.shift = false;
|
|
||||||
Application.keyboard.capsLock = !Application.keyboard.capsLock;
|
|
||||||
let capsLockButton = $('[data-value="capslock"]');
|
|
||||||
capsLockButton.toggleClass('active');
|
|
||||||
setKeyboardLayout('default', Application.keyboard.capsLock ? 'shift' : '');
|
|
||||||
break;
|
|
||||||
case 'space':
|
|
||||||
input = ' ';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//Stops keys such as F5 being pressed.
|
|
||||||
if (input.length == 1) {
|
|
||||||
if (Application.keyboard.shift || Application.keyboard.capsLock) {
|
|
||||||
input = input.toUpperCase();
|
|
||||||
//If shift, reload lowercase
|
|
||||||
if (Application.keyboard.shift) {
|
|
||||||
Application.keyboard.shift = false;
|
|
||||||
setKeyboardLayout('default');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let newText = inputBox.val() + input;
|
|
||||||
keyboard.data('value', newText);
|
|
||||||
inputBox.val(newText);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let setKeyboardLayout = (layout, modifier = '') => {
|
|
||||||
if (modifier != '')
|
|
||||||
modifier = `_${modifier}`;
|
|
||||||
Application.keyboard.currentLayout = layout;
|
|
||||||
let layoutToLoad = Application.keyboard.layouts[layout];
|
|
||||||
$('.virtualKeyboardRow').each((index, row) => {
|
|
||||||
/*
|
|
||||||
We start at 1 instead of 0. Makes it easier for non-programmers
|
|
||||||
and translators making their own language packs
|
|
||||||
*/
|
|
||||||
index = index + 1;
|
|
||||||
// @ts-ignore
|
|
||||||
let currentRow = layoutToLoad[`row${index}${modifier}`];
|
|
||||||
$(row).children('a').each((keyIndex, button) => {
|
|
||||||
let key = $(button);
|
|
||||||
let keyValue = currentRow[keyIndex];
|
|
||||||
/*
|
|
||||||
KeyText is the text that appears
|
|
||||||
in the button. KeyData is the value
|
|
||||||
submitted when the button is pressed.
|
|
||||||
*/
|
|
||||||
let keyText = keyValue;
|
|
||||||
let keyData = keyValue;
|
|
||||||
key.addClass('posButton');
|
|
||||||
key.addClass('virtualKeyboardButton');
|
|
||||||
let pattern = new RegExp(/\[([^)]+)\]/);
|
|
||||||
let matches = keyValue.match(pattern);
|
|
||||||
if (matches) {
|
|
||||||
keyText = keyValue.replace(pattern, '');
|
|
||||||
keyData = matches[1];
|
|
||||||
}
|
|
||||||
key.html(keyText);
|
|
||||||
//Use attr() as some keys have CSS dependent on data-value
|
|
||||||
key.attr('data-value', keyData);
|
|
||||||
key.data('value', keyData);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
$(() => {
|
|
||||||
setupVirtualNumpad();
|
|
||||||
ajax('/ajax/getKeyboardLayout/english', null, 'get', setupVirtualKeyboard, null, null);
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=keyboards.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"keyboards.js","sourceRoot":"","sources":["../ts/keyboards.ts"],"names":[],"mappings":"AAMA,IAAI,iBAAiB,GAAG,CAAC,OAAe,EAAE,SAAS,GAAG,CAAC,EAAE,UAAmB,EAAE,aAAa,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,EAAE,cAAwB,EAAE,EAAE;IAC3I,IAAI,MAAM,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACjC,IAAI,QAAQ,GAAG,CAAC,CAAC,qBAAqB,CAAC,CAAA;IACvC,IAAI,mBAAmB,GAAG,CAAC,CAAC,iBAAiB,CAAC,CAAA;IAE9C,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IAE7B,IAAI,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAA;IAClD,mBAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,eAA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AC,OAAO,EAAE,EAAE,CAAC,CAAA;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAChB,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;IACrC,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;IACrC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAA;IAC/C,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACxC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACzLine truncated
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
//# sourceMappingURL=test.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["../ts/test.ts"],"names":[],"mappings":""}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
//# sourceMappingURL=types.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":""}
|
|
||||||
Reference in new issue
Block a user