#7874 clientObservationType #2960

Merged
jorgep merged 23 commits from 7874-createObservationType into dev 2024-10-14 14:16:41 +00:00
10 changed files with 39 additions and 101 deletions

View File

@ -546,7 +546,8 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`)
(6, 'Weight', 'weight'),
(7, 'InvoiceOut', 'invoiceOut'),
(8, 'DropOff', 'dropOff'),
(9, 'Sustitución', 'substitution');
(9, 'Sustitución', 'substitution'),
(10, 'Finance', 'finance');
INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`)
VALUES

View File

@ -0,0 +1,3 @@
ALTER TABLE vn.clientObservation
ADD COLUMN observationTypeFk TINYINT(3) UNSIGNED NOT NULL,
ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES vn.observationType(id);

View File

@ -0,0 +1,3 @@
INSERT IGNORE INTO vn.observationType
Review

los archivos .vn no funcionan, lo inserto desde dbeaver

los archivos .vn no funcionan, lo inserto desde dbeaver
SET description = 'Finance',
code = 'finance';

View File

@ -1,42 +0,0 @@
import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
describe('Client Add notes path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'client');
await page.accessToSearchResult('Bruce Banner');
await page.accessToSection('client.card.note.index');
});
afterAll(async() => {
await browser.close();
});
it(`should reach the notes index`, async() => {
await page.waitForState('client.card.note.index');
});
it(`should click on the add note button`, async() => {
await page.waitToClick(selectors.clientNotes.addNoteFloatButton);
await page.waitForState('client.card.note.create');
});
it(`should create a note`, async() => {
await page.waitForSelector(selectors.clientNotes.note);
await page.type(`${selectors.clientNotes.note} textarea`, 'Meeting with Black Widow 21st 9am');
await page.waitToClick(selectors.clientNotes.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should confirm the note was created', async() => {
const result = await page.waitToGetProperty(selectors.clientNotes.firstNoteText, 'innerText');
expect(result).toEqual('Meeting with Black Widow 21st 9am');
});
});

View File

@ -28,12 +28,12 @@ describe('Client defaulter path', () => {
const salesPersonName =
await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText');
expect(clientName).toEqual('Bruce Banner');
expect(salesPersonName).toEqual('developer');
expect(clientName).toEqual('Ororo Munroe');
expect(salesPersonName).toEqual('salesperson');
});
it('should first observation not changed', async() => {
const expectedObservation = 'Meeting with Black Widow 21st 9am';
const expectedObservation = 'Madness, as you know, is like gravity, all it takes is a little push';
const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value');
expect(result).toContain(expectedObservation);
@ -62,13 +62,4 @@ describe('Client defaulter path', () => {
await page.write(selectors.clientDefaulter.observation, 'My new observation');
await page.waitToClick(selectors.clientDefaulter.saveButton);
});
it('should first observation changed', async() => {
const message = await page.waitForSnackbar();
await page.waitForSelector(selectors.clientDefaulter.firstObservation);
const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value');
expect(message.text).toContain('Observation saved!');
expect(result).toContain('My new observation');
});
});

View File

@ -381,5 +381,6 @@
"The entry does not have stickers": "La entrada no tiene etiquetas",
"This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
"No valid travel thermograph found": "No se encontró un termógrafo válido",
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea"
}
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea",
"type cannot be blank": "Se debe rellenar el tipo"
}

View File

@ -1,8 +1,11 @@
module.exports = function(Self) {
Self.validate('text', isEnabled, {message: 'Description cannot be blank'});
function isEnabled(err) {
Self.validate('text', function(err) {
if (!this.text) err();
}
}, {message: 'Description cannot be blank'});
Self.validate('observationTypeFk', function(err) {
if (!this.observationTypeFk) err();
}, {message: 'type cannot be blank'});
Self.observe('before save', function(ctx, next) {
ctx.instance.created = Date();

View File

@ -1,10 +1,10 @@
{
"name": "ClientObservation",
"name": "ClientObservation",
"description": "Client notes",
"base": "VnModel",
"mixins": {
"Loggable": true
},
"mixins": {
"Loggable": true
},
"options": {
"mysql": {
"table": "clientObservation"
@ -26,6 +26,10 @@
"created": {
"type": "date",
"description": "Creation date and time"
},
"observationTypeFk": {
"type": "number",
"description": "Type of observation"
}
},
"relations": {
@ -44,14 +48,18 @@
"include": {
"relation": "worker",
"scope": {
"fields": ["id"],
"fields": [
"id"
],
"include": {
"relation": "user",
"scope": {
"fields": ["nickname"]
"fields": [
"nickname"
]
}
}
}
}
}
}
}

View File

@ -1,31 +0,0 @@
<vn-crud-model
vn-id="model"
url="clientObservations"
filter="$ctrl.filter"
link="{clientFk: $ctrl.$params.id}"
data="notes"
auto-load="true">
</vn-crud-model>
<vn-data-viewer
model="model"
class="vn-w-md">
<vn-card class="vn-pa-md">
<div
ng-repeat="note in notes"
class="note vn-pa-sm border-solid border-radius vn-mb-md">
<vn-horizontal class="vn-mb-sm" style="color: #666">
<vn-one>{{::note.worker.user.nickname}}</vn-one>
<vn-auto>{{::note.created | date:'dd/MM/yyyy HH:mm'}}</vn-auto>
</vn-horizontal>
<vn-horizontal class="text">
{{::note.text}}
</vn-horizontal>
</div>
</vn-card>
</vn-data-viewer>
<a vn-tooltip="New note"
ui-sref="client.card.note.create({id: $ctrl.$params.id})"
vn-bind="+"
fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>
</a>

View File

@ -5,9 +5,10 @@ import './style.scss';
export default class Controller extends Section {
constructor($element, $) {
super($element, $);
this.filter = {
order: 'created DESC',
};
}
async $onInit() {
this.$state.go('home');
window.location.href = await this.vnApp.getUrl(`customer/${this.$params.id}/notes`);
}
}