fixes #5063 Añadir campo doPhoto en la ficha de Item #1264

Merged
joan merged 19 commits from 5063-item-module-doPhoto into dev 2023-03-02 06:34:46 +00:00
7 changed files with 42 additions and 2 deletions

View File

@ -57,6 +57,7 @@ module.exports = Self => {
const itemType = await models.ItemType.findById(params.typeFk, {fields: ['isLaid']}, myOptions); const itemType = await models.ItemType.findById(params.typeFk, {fields: ['isLaid']}, myOptions);
params.isLaid = itemType.isLaid; params.isLaid = itemType.isLaid;
params.isPhotoRequested = true;
const item = await models.Item.create(params, myOptions); const item = await models.Item.create(params, myOptions);

View File

@ -146,6 +146,12 @@
}, },
"isLaid": { "isLaid": {
"type": "boolean" "type": "boolean"
},
"isPhotoRequested": {
"type": "boolean",
"mysql":{
"columnName": "doPhoto"
}
} }
}, },
"relations": { "relations": {

View File

@ -182,6 +182,12 @@
ng-model="$ctrl.item.isFragile" ng-model="$ctrl.item.isFragile"
info="Is shown at website, app that this item cannot travel (wreath, palms, ...)"> info="Is shown at website, app that this item cannot travel (wreath, palms, ...)">
</vn-check> </vn-check>
<vn-check
vn-one
label="Do photo"
ng-model="$ctrl.item.isPhotoRequested"
info="This item does need a photo">
</vn-check>
</vn-horizontal> </vn-horizontal>
</vn-card> </vn-card>
<vn-button-bar> <vn-button-bar>

View File

@ -12,3 +12,5 @@ Fragile: Frágil
Is shown at website, app that this item cannot travel (wreath, palms, ...): Se muestra en la web, app que este artículo no puede viajar (coronas, palmas, ...) Is shown at website, app that this item cannot travel (wreath, palms, ...): Se muestra en la web, app que este artículo no puede viajar (coronas, palmas, ...)
Multiplier: Multiplicador Multiplier: Multiplicador
Generic: Genérico Generic: Genérico
This item does need a photo: Este artículo necesita una foto
Do photo: Hacer foto

View File

@ -91,6 +91,9 @@ class Controller extends Descriptor {
this.$.photo.setAttribute('src', newSrc); this.$.photo.setAttribute('src', newSrc);
this.$.photo.setAttribute('zoom-image', newZoomSrc); this.$.photo.setAttribute('zoom-image', newZoomSrc);
if (this.item.isPhotoRequested)
this.$http.patch(`Items/${this.item.id}`, {isPhotoRequested: false});
} }
getWarehouseName(warehouseFk) { getWarehouseName(warehouseFk) {

View File

@ -8,7 +8,8 @@ describe('vnItemDescriptor', () => {
id: 1, id: 1,
itemType: { itemType: {
warehouseFk: 1 warehouseFk: 1
} },
isPhotoRequested: true
}; };
const stock = { const stock = {
visible: 1, visible: 1,
@ -43,4 +44,16 @@ describe('vnItemDescriptor', () => {
expect(controller.item).toEqual(item); expect(controller.item).toEqual(item);
}); });
}); });
describe('onUploadResponse()', () => {
it(`should change isPhotoRequested when a new photo is uploaded`, () => {
controller.item = item;
controller.$rootScope = {imagePath: () => {}};
controller.$.photo = {setAttribute: () => {}};
$httpBackend.expectPATCH(`Items/${item.id}`).respond(200);
controller.onUploadResponse();
$httpBackend.flush();
});
});
}); });

View File

@ -75,6 +75,15 @@
{{$ctrl.summary.item.itemType.worker.user.name}} {{$ctrl.summary.item.itemType.worker.user.name}}
</span> </span>
</vn-label-value> </vn-label-value>
<vn-horizontal>
<vn-check
label="Do photo"
disabled="true"
vn-one
ng-model="$ctrl.item.isPhotoRequested"
info="This item does need a photo">
</vn-check>
</vn-horizontal>
</vn-one> </vn-one>
<vn-one name="otherData"> <vn-one name="otherData">
<h4 ng-show="$ctrl.isBuyer"> <h4 ng-show="$ctrl.isBuyer">