7430_devToTest #2490
|
@ -1,3 +1,6 @@
|
||||||
|
ALTER TABLE vn.worker MODIFY COLUMN locker varchar(10) DEFAULT NULL NULL;
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE `vn`.`locker` (
|
CREATE TABLE `vn`.`locker` (
|
||||||
`code` varchar(10) DEFAULT NULL,
|
`code` varchar(10) DEFAULT NULL,
|
||||||
`gender` varchar(255) DEFAULT NULL,
|
`gender` varchar(255) DEFAULT NULL,
|
||||||
|
@ -8,6 +11,14 @@ CREATE TABLE `vn`.`locker` (
|
||||||
CONSTRAINT `locker_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`)
|
CONSTRAINT `locker_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`worker`
|
||||||
|
ADD CONSTRAINT `worker_locker_fk`
|
||||||
|
FOREIGN KEY (`locker`)
|
||||||
|
REFERENCES `vn`.`locker` (`code`)
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
ON DELETE SET NULL;
|
||||||
|
|
||||||
|
|
||||||
-- Insertar taquillas disponibles para mujeres (1A - 73A / 1B - 73B)
|
-- Insertar taquillas disponibles para mujeres (1A - 73A / 1B - 73B)
|
||||||
INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES
|
INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES
|
||||||
('1A', 'M', NULL), ('2A', 'M', NULL), ('3A', 'M', NULL), ('4A', 'M', NULL), ('5A', 'M', NULL), ('6A', 'M', NULL), ('7A', 'M', NULL),
|
('1A', 'M', NULL), ('2A', 'M', NULL), ('3A', 'M', NULL), ('4A', 'M', NULL), ('5A', 'M', NULL), ('6A', 'M', NULL), ('7A', 'M', NULL),
|
||||||
|
@ -19,5 +30,4 @@ INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES
|
||||||
('200B', 'F', NULL), ('201B', 'F', NULL), ('202B', 'F', NULL), ('203B', 'F', NULL), ('204B', 'F', NULL), ('205B', 'F', NULL), ('206B', 'F', NULL);
|
('200B', 'F', NULL), ('201B', 'F', NULL), ('202B', 'F', NULL), ('203B', 'F', NULL), ('204B', 'F', NULL), ('205B', 'F', NULL), ('206B', 'F', NULL);
|
||||||
|
|
||||||
|
|
||||||
-- Eliminar locker
|
|
||||||
ALTER TABLE `vn`.`worker` DROP COLUMN `locker`;
|
|
|
@ -1,32 +0,0 @@
|
||||||
|
|
||||||
module.exports = Self => {
|
|
||||||
Self.remoteMethod('chooseLocker', {
|
|
||||||
description: 'Returns an unoccupied locker for the employee',
|
|
||||||
accessType: 'WRITE',
|
|
||||||
accepts: [{
|
|
||||||
arg: 'filter',
|
|
||||||
type: 'Object',
|
|
||||||
description: 'Filter defining where and paginated data',
|
|
||||||
required: true
|
|
||||||
}],
|
|
||||||
returns: {
|
|
||||||
type: ['object'],
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/chooseLocker`,
|
|
||||||
verb: 'GET'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.chooseLocker = async filter => {
|
|
||||||
const query =
|
|
||||||
`SELECT l.code
|
|
||||||
FROM worker w
|
|
||||||
JOIN locker l ON w.sex = l.gender
|
|
||||||
WHERE w.id = ? AND l.workerFk IS NULL;
|
|
||||||
`[this.worker.id];
|
|
||||||
|
|
||||||
return Self.chooseLocker(query, filter);
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -116,7 +116,7 @@
|
||||||
"Operator": {
|
"Operator": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"locker": {
|
"Locker": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
module.exports = Self => {
|
|
||||||
require('../methods/worker/chooseLocker')(Self);
|
|
||||||
|
|
||||||
Self.validatesUniquenessOf('locker', {
|
|
||||||
message: 'This locker has already been assigned'
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "locker",
|
"name": "Locker",
|
||||||
"description": "Employee's locker",
|
"description": "Employee's locker",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "locker"
|
"table": "locker"
|
||||||
|
|
|
@ -88,6 +88,11 @@
|
||||||
"type": "hasMany",
|
"type": "hasMany",
|
||||||
"model": "WorkerTeamCollegues",
|
"model": "WorkerTeamCollegues",
|
||||||
"foreignKey": "workerFk"
|
"foreignKey": "workerFk"
|
||||||
|
},
|
||||||
|
"locker": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Locker",
|
||||||
|
"foreignKey": "code"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Locker"
|
label="Locker"
|
||||||
url="Lockers"
|
url="Lockers"
|
||||||
data="$ctrl.locker.code">
|
ng-model="$ctrl.locker.code">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
|
|
|
@ -13,9 +13,15 @@ class Controller extends Section {
|
||||||
return this.$.watcher.submit()
|
return this.$.watcher.submit()
|
||||||
.then(() => this.card.reload());
|
.then(() => this.card.reload());
|
||||||
}
|
}
|
||||||
|
async chooseLocker() {
|
||||||
|
const locker =
|
||||||
|
`SELECT l.code
|
||||||
|
FROM worker w
|
||||||
|
JOIN locker l ON w.sex = l.gender
|
||||||
|
WHERE w.id = ? AND l.workerFk IS NULL;
|
||||||
|
`[this.code];
|
||||||
|
|
||||||
chooseLocker() {
|
return locker;
|
||||||
//
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
></vn-link-phone>
|
></vn-link-phone>
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value label="Locker"
|
<vn-label-value label="Locker"
|
||||||
value="{{::locker.code}}">
|
value="{{worker.locker.code}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
<vn-one>
|
<vn-one>
|
||||||
|
|
|
@ -52,6 +52,10 @@ class Controller extends Summary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
relation: 'locker',
|
||||||
|
scope: {fields: ['code']}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue