clone zone with calenday days (#1482) & fixed clone hour #1458
gitea/salix/test This commit looks good
Details
gitea/salix/test This commit looks good
Details
This commit is contained in:
parent
16d91d0999
commit
d169a66e19
|
@ -22,6 +22,7 @@ module.exports = Self => {
|
|||
Self.clone = async id => {
|
||||
const models = Self.app.models;
|
||||
const transaction = await Self.beginTransaction({});
|
||||
const options = {transaction};
|
||||
|
||||
// Find original zone
|
||||
const zone = await models.Zone.findOne({
|
||||
|
@ -35,22 +36,36 @@ module.exports = Self => {
|
|||
'bonus',
|
||||
'isVolumetric'],
|
||||
where: {id}
|
||||
});
|
||||
}, options);
|
||||
|
||||
const hour = zone.hour;
|
||||
const offset = hour.getTimezoneOffset() * 60000;
|
||||
hour.setTime(hour.getTime() + offset);
|
||||
|
||||
// Find all original included geolocations
|
||||
const includedGeo = await models.ZoneIncluded.find({
|
||||
fields: ['geoFk', 'isIncluded'],
|
||||
where: {zoneFk: id}
|
||||
});
|
||||
}, options);
|
||||
|
||||
// Find all original selected days
|
||||
const calendarDays = await models.ZoneCalendar.find({
|
||||
where: {zoneFk: id}
|
||||
}, options);
|
||||
|
||||
try {
|
||||
const newZone = await Self.create(zone, {transaction});
|
||||
const newZone = await Self.create(zone, options);
|
||||
const newIncludedGeo = includedGeo.map(included => {
|
||||
included.zoneFk = newZone.id;
|
||||
return included;
|
||||
});
|
||||
const newCalendayDays = calendarDays.map(day => {
|
||||
day.zoneFk = newZone.id;
|
||||
return day;
|
||||
});
|
||||
|
||||
await models.ZoneIncluded.create(newIncludedGeo, {transaction});
|
||||
await models.ZoneIncluded.create(newIncludedGeo, options);
|
||||
await models.ZoneCalendar.create(newCalendayDays, options);
|
||||
await transaction.commit();
|
||||
|
||||
return newZone;
|
||||
|
|
|
@ -48,6 +48,6 @@
|
|||
<vn-confirm
|
||||
vn-id="delete-zone"
|
||||
on-response="$ctrl.returnDialog(response)"
|
||||
question="Delete zone"
|
||||
message="Are you sure you want to delete this zone?">
|
||||
question="Are you sure you want to delete this zone?"
|
||||
message="This zone will be removed">
|
||||
</vn-confirm>
|
|
@ -1,2 +1,2 @@
|
|||
Do you want to clone this zone?: ¿Seguro que quieres eliminar esta zona?
|
||||
Do you want to clone this zone?: ¿Seguro que quieres clonar esta zona?
|
||||
All it's properties will be copied: Todas sus propiedades serán copiadas
|
|
@ -4,8 +4,8 @@ Hour: Hora (ETD)
|
|||
ETD: Tiempo de salida estimado
|
||||
Price: Precio
|
||||
Locations: Localizaciones
|
||||
Delete zone: Eliminar zona
|
||||
Are you sure you want to delete this zone?: ¿Estás seguro de querer eliminar esta zona?
|
||||
This zone will be removed: La zona será eliminada
|
||||
Are you sure you want to delete this zone?: ¿Seguro de que quieres eliminar esta zona?
|
||||
Zones: Zonas
|
||||
New zone: Nueva zona
|
||||
Volumetric: Volumétrico
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
value="{{$ctrl.summary.price | currency: 'EUR': 2}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Bonus"
|
||||
value="{{$ctrl.summary.price | currency: 'EUR': 2}}">
|
||||
value="{{$ctrl.summary.bonus | currency: 'EUR': 2}}">
|
||||
</vn-label-value>
|
||||
<vn-vertical>
|
||||
<vn-check label="Volumetric" disabled="true"
|
||||
|
|
Loading…
Reference in New Issue