1. Редактор карты зала.
This commit is contained in:
miroman-afk
2022-10-27 15:48:02 +03:00
parent 0e5f2002b1
commit 4d3ad7727d
21 changed files with 625 additions and 192 deletions

View File

@@ -6,7 +6,7 @@
RoommapCtrl.$inject = ['$scope', 'smartRequest', 'Notification', '$http'];
function RoommapCtrl($scope, smartRequest, Notification, $http) {
function RoommapCtrl($scope, smartRequest, Notification) {
$scope.places = [];
$scope.tables = [];
$scope.newTables = [];
@@ -28,7 +28,6 @@
$('#save_tables').hide();
$('#save_places').hide();
$scope.roommap = data.roommap;
Notification.success(data.status);
});
};
@@ -98,7 +97,6 @@
smartRequest.get('v1/roommap?type=place&id=' + place_id, function (data) {
$scope.place = data.place;
$scope.place_id = data.place_id;
Notification.success(data.status);
$scope.left = document.getElementById('tables').getBoundingClientRect().left;
$scope.top = parseInt(document.getElementById('view').clientHeight) - parseInt(document.getElementById('background_1').offsetHeight) - 2;
$scope.percentWidth = document.getElementById('tables').clientWidth / 1024;
@@ -141,7 +139,7 @@
return $scope.tables;
};
$scope.duplicateTable = function (index, place) {
$scope.duplicateTable = function (index) {
$scope.newTable = {};
$scope.lastEl = $scope.tables.length;
$scope.newTable.id = $scope.tables[$scope.lastEl - 1].id + 1,
@@ -151,7 +149,8 @@
$scope.newTable.width = $scope.tables[index].width,
$scope.newTable.height = $scope.tables[index].height,
$scope.newTable.x = $scope.tables[index].x + 50,
$scope.newTable.y = $scope.tables[index].y + 50;
$scope.newTable.y = $scope.tables[index].y + 50,
$scope.newTable.type = $scope.tables[index].type;
$scope.tables.push($scope.newTable);
$('#save_tables').show();
return $scope.tables;
@@ -163,17 +162,19 @@
$scope.tableHeight = table.height;
$scope.tableName = table.name;
$scope.tableId = table.table_id;
$scope.tableType = table.type.toString();
$scope.tableIndex = $index;
console.log($scope.tableIndex);
$('#save_tables').show();
return $scope.tables;
};
$scope.saveTable = function (index, id, name, width, height) {
$scope.saveTable = function (index, id, name, width, height, type) {
$('#table-edit').modal('toggle');
$scope.tables[index].width = width,
$scope.tables[index].height = height,
$scope.tables[index].name = name,
$scope.tables[index].type = parseInt(type),
$scope.tables[index].table_id = id;
$('#save_tables').show();
@@ -205,6 +206,35 @@
});
};
$scope.createTable = function (place_id) {
$scope.editPlaceTableId = place_id;
$('#table-create').modal('show');
};
$scope.saveNewTable = function (place_id, name, type) {
$scope.newTable = {};
$scope.lastEl = parseInt($scope.tables.length);
if ($scope.lastEl == 0) {
$scope.newTableID = 1;
$scope.newTableTableID = 1;
} else {
$scope.newTableID = $scope.tables[$scope.lastEl - 1].id + 1;
$scope.newTableTableID = $scope.tables[$scope.lastEl - 1].table_id + 1;
}
$scope.newTable.id = $scope.newTableID,
$scope.newTable.place_id = place_id,
$scope.newTable.table_id = $scope.newTableTableID,
$scope.newTable.name = name,
$scope.newTable.width = 100,
$scope.newTable.height = 100,
$scope.newTable.x = 100,
$scope.newTable.y = 100,
$scope.newTable.type = parseInt(type);
$scope.tables.push($scope.newTable);
$('#table-create').modal('toggle');
$('#save_tables').show();
}
$scope.deletePlace = function (index) {
console.log(index);
delete $scope.roommap.splice(index, 1);
@@ -212,12 +242,39 @@
return $scope.roommap;
};
$scope.editPlace = function (index) {
$scope.editPlace = function (id, place) {
$scope.editPlaceId = id;
$scope.editPlaceName = place;
$('#place-edit').modal('show');
};
$scope.savePlace = function (index) {
$scope.updatePlace = function (id, place) {
$('#place-edit').modal('toggle');
smartRequest.post('v1/roommap', {
type: 'place',
action: 'update',
id: id,
name: place,
}, function (data) {
Notification.success(data.message);
$scope.getRoomMap();
});
};
$scope.createPlace = function () {
$('#place-create').modal('show');
};
$scope.savePlace = function (place) {
$('#place-create').modal('toggle');
smartRequest.post('v1/roommap', {
type: 'place',
action: 'create',
name: place,
}, function (data) {
Notification.success(data.message);
$scope.getRoomMap();
});
};
$scope.savePlaces = function (places) {
@@ -227,6 +284,7 @@
action: 'saveplaces',
places: JSON.stringify(places),
}, function (data) {
$('#save_places').hide();
Notification.success(data.message);
/*$scope.getRoomMap();*/
});