Merge branch 'dev' into 5824-fixUpsertFixedPrice
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
25ce685116
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
||||||
|
VALUES
|
||||||
|
('Vehicle','sorted','WRITE','ALLOW','employee');
|
|
@ -77831,7 +77831,7 @@ BEGIN
|
||||||
LEAVE cur1Loop;
|
LEAVE cur1Loop;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL zone_getLeaves2(vZoneFk, NULL, NULL);
|
CALL zone_getLeaves(vZoneFk, NULL, NULL, TRUE);
|
||||||
|
|
||||||
myLoop: LOOP
|
myLoop: LOOP
|
||||||
SET vGeoFk = NULL;
|
SET vGeoFk = NULL;
|
||||||
|
@ -77844,7 +77844,7 @@ BEGIN
|
||||||
LEAVE myLoop;
|
LEAVE myLoop;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL zone_getLeaves2(vZoneFk, vGeoFk, NULL);
|
CALL zone_getLeaves(vZoneFk, vGeoFk, NULL, TRUE);
|
||||||
UPDATE tmp.zoneNodes
|
UPDATE tmp.zoneNodes
|
||||||
SET isChecked = TRUE
|
SET isChecked = TRUE
|
||||||
WHERE geoFk = vGeoFk;
|
WHERE geoFk = vGeoFk;
|
||||||
|
@ -78130,19 +78130,25 @@ DELIMITER ;
|
||||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||||
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
|
||||||
DELIMITER ;;
|
DELIMITER ;;
|
||||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLeaves`(vSelf INT, vParentFk INT, vSearch VARCHAR(255))
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getLeaves`(
|
||||||
|
vSelf INT,
|
||||||
|
vParentFk INT,
|
||||||
|
vSearch VARCHAR(255),
|
||||||
|
vHasInsert BOOL
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk.
|
* Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk.
|
||||||
* @param vSelf Id de la zona
|
* @param vSelf Id de la zona
|
||||||
* @param vParentFk Id del geo a calcular
|
* @param vParentFk Id del geo a calcular
|
||||||
* @param vSearch cadena a buscar
|
* @param vSearch Cadena a buscar
|
||||||
|
* @param vHasInsert Indica si inserta en tmp.zoneNodes
|
||||||
|
* Optional @table tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk)
|
||||||
*/
|
*/
|
||||||
DECLARE vIsNumber BOOL;
|
DECLARE vIsNumber BOOL;
|
||||||
DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch != '';
|
DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch <> '';
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tNodes;
|
CREATE OR REPLACE TEMPORARY TABLE tNodes
|
||||||
CREATE TEMPORARY TABLE tNodes
|
|
||||||
(UNIQUE (id))
|
(UNIQUE (id))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT id
|
SELECT id
|
||||||
|
@ -78167,18 +78173,15 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF vParentFk IS NULL THEN
|
IF vParentFk IS NULL THEN
|
||||||
DROP TEMPORARY TABLE IF EXISTS tChilds;
|
CREATE OR REPLACE TEMPORARY TABLE tChilds
|
||||||
CREATE TEMPORARY TABLE tChilds
|
(INDEX(id))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT id
|
SELECT id FROM tNodes;
|
||||||
FROM tNodes;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tParents;
|
CREATE OR REPLACE TEMPORARY TABLE tParents
|
||||||
CREATE TEMPORARY TABLE tParents
|
(INDEX(id))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT id
|
SELECT id FROM zoneGeo LIMIT 0;
|
||||||
FROM zoneGeo
|
|
||||||
LIMIT 0;
|
|
||||||
|
|
||||||
myLoop: LOOP
|
myLoop: LOOP
|
||||||
DELETE FROM tParents;
|
DELETE FROM tParents;
|
||||||
|
@ -78189,40 +78192,64 @@ BEGIN
|
||||||
WHERE g.parentFk IS NOT NULL;
|
WHERE g.parentFk IS NOT NULL;
|
||||||
|
|
||||||
INSERT IGNORE INTO tNodes
|
INSERT IGNORE INTO tNodes
|
||||||
SELECT id
|
SELECT id FROM tParents;
|
||||||
FROM tParents;
|
|
||||||
|
|
||||||
IF ROW_COUNT() = 0 THEN
|
IF NOT ROW_COUNT() THEN
|
||||||
LEAVE myLoop;
|
LEAVE myLoop;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
DELETE FROM tChilds;
|
DELETE FROM tChilds;
|
||||||
INSERT INTO tChilds
|
INSERT INTO tChilds
|
||||||
SELECT id
|
SELECT id FROM tParents;
|
||||||
FROM tParents;
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tChilds, tParents;
|
DROP TEMPORARY TABLE tChilds, tParents;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF !vIsSearch THEN
|
IF NOT vIsSearch THEN
|
||||||
INSERT IGNORE INTO tNodes
|
INSERT IGNORE INTO tNodes
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM zoneGeo
|
FROM zoneGeo
|
||||||
WHERE parentFk <=> vParentFk;
|
WHERE parentFk <=> vParentFk;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tZones
|
||||||
SELECT g.id,
|
SELECT g.id,
|
||||||
g.name,
|
g.name,
|
||||||
g.parentFk,
|
g.parentFk,
|
||||||
g.sons,
|
g.sons,
|
||||||
isIncluded selected
|
NOT g.sons OR `type` = 'country' isChecked,
|
||||||
|
i.isIncluded selected,
|
||||||
|
g.`depth`,
|
||||||
|
vSelf
|
||||||
FROM zoneGeo g
|
FROM zoneGeo g
|
||||||
JOIN tNodes n ON n.id = g.id
|
JOIN tNodes n ON n.id = g.id
|
||||||
LEFT JOIN zoneIncluded i ON i.geoFk = g.id AND i.zoneFk = vSelf
|
LEFT JOIN zoneIncluded i ON i.geoFk = g.id
|
||||||
ORDER BY `depth`, selected DESC, name;
|
AND i.zoneFk = vSelf
|
||||||
|
ORDER BY g.`depth`, selected DESC, g.name;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tNodes;
|
IF vHasInsert THEN
|
||||||
|
INSERT IGNORE INTO tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk)
|
||||||
|
SELECT id,
|
||||||
|
name,
|
||||||
|
parentFk,
|
||||||
|
sons,
|
||||||
|
isChecked,
|
||||||
|
vSelf
|
||||||
|
FROM tZones
|
||||||
|
WHERE selected
|
||||||
|
OR (selected IS NULL AND vParentFk IS NOT NULL);
|
||||||
|
ELSE
|
||||||
|
SELECT id,
|
||||||
|
name,
|
||||||
|
parentFk,
|
||||||
|
sons,
|
||||||
|
selected
|
||||||
|
FROM tZones
|
||||||
|
ORDER BY `depth`, selected DESC, name;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tNodes, tZones;
|
||||||
END ;;
|
END ;;
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||||
|
@ -78540,7 +78567,7 @@ BEGIN
|
||||||
INDEX(geoFk))
|
INDEX(geoFk))
|
||||||
ENGINE = MEMORY;
|
ENGINE = MEMORY;
|
||||||
|
|
||||||
CALL zone_getLeaves2(vSelf, NULL , NULL);
|
CALL zone_getLeaves(vSelf, NULL , NULL, TRUE);
|
||||||
|
|
||||||
UPDATE tmp.zoneNodes zn
|
UPDATE tmp.zoneNodes zn
|
||||||
SET isChecked = 0
|
SET isChecked = 0
|
||||||
|
@ -78553,7 +78580,7 @@ BEGIN
|
||||||
WHERE NOT isChecked
|
WHERE NOT isChecked
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
CALL zone_getLeaves2(vSelf, vGeoFk, NULL);
|
CALL zone_getLeaves(vSelf, vGeoFk, NULL, TRUE);
|
||||||
UPDATE tmp.zoneNodes
|
UPDATE tmp.zoneNodes
|
||||||
SET isChecked = TRUE
|
SET isChecked = TRUE
|
||||||
WHERE geoFk = vGeoFk;
|
WHERE geoFk = vGeoFk;
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('sorted', {
|
||||||
|
description: 'Sort the vehicles by warehouse',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'warehouseFk',
|
||||||
|
type: 'number'
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/sorted`,
|
||||||
|
verb: `POST`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.sorted = async warehouseFk => {
|
||||||
|
return Self.rawSql(`
|
||||||
|
SELECT v.id, v.warehouseFk, v.numberPlate, w.name
|
||||||
|
FROM vehicle v
|
||||||
|
JOIN warehouse w ON w.id = v.warehouseFk
|
||||||
|
ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC;
|
||||||
|
`, [warehouseFk]);
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
require('../methods/vehicle/sorted')(Self);
|
||||||
|
};
|
|
@ -23,12 +23,14 @@
|
||||||
</tpl-item>
|
</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
label="Vehicle"
|
||||||
ng-model="$ctrl.route.vehicleFk"
|
ng-model="$ctrl.route.vehicleFk"
|
||||||
url="Vehicles"
|
data="$ctrl.vehicles"
|
||||||
show-field="numberPlate"
|
show-field="numberPlate"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
label="Vehicle"
|
order="false"
|
||||||
vn-name="vehicle">
|
vn-name="vehicle">
|
||||||
|
<tpl-item>{{::numberPlate}} - {{::name}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
|
|
|
@ -2,6 +2,13 @@ import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
|
$onInit() {
|
||||||
|
this.$http.post(`Vehicles/sorted`, {warehouseFk: this.vnConfig.warehouseFk})
|
||||||
|
.then(res => {
|
||||||
|
this.vehicles = res.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.$.watcher.submit().then(() =>
|
this.$.watcher.submit().then(() =>
|
||||||
this.card.reload()
|
this.card.reload()
|
||||||
|
|
|
@ -38,7 +38,7 @@ module.exports = Self => {
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const [res] = await Self.rawSql(
|
const [res] = await Self.rawSql(
|
||||||
`CALL zone_getLeaves(?, ?, ?)`,
|
`CALL zone_getLeaves(?, ?, ?, FALSE)`,
|
||||||
[id, parentId, search],
|
[id, parentId, search],
|
||||||
myOptions
|
myOptions
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue