#1297 Angular material removed from project

This commit is contained in:
Juan Ferrer 2019-09-30 20:46:22 +02:00
parent 80e1f5d476
commit 679c6af0df
12 changed files with 505 additions and 424 deletions

View File

@ -483,26 +483,28 @@ let actions = {
checkboxState: function(selector, done) { checkboxState: function(selector, done) {
this.wait(selector) this.wait(selector)
.evaluate(checkboxSelector => { .evaluate(selector => {
return document.querySelector(checkboxSelector).getAttribute('class'); let checkbox = document.querySelector(selector);
switch (checkbox.$ctrl.field) {
case null:
return 'intermediate';
case true:
return 'checked';
default:
return 'unchecked';
}
}, selector) }, selector)
.then(elementClass => { .then(res => done(null, res))
let classList = elementClass.split(' '); .catch(done);
let className; },
if (classList.includes('md-checked')) isDisabled: function(selector, done) {
className = 'checked'; this.wait(selector)
if (classList.includes('md-intermediate')) .evaluate(selector => {
className = 'intermediate'; let element = document.querySelector(selector);
if (!classList.includes('md-intermediate') && !classList.includes('md-checked')) return element.$ctrl.disabled;
className = 'unchecked'; }, selector)
.then(res => done(null, res))
if (!className)
throw new Error(`selector: ${selector} is not a md-checkbox`);
done(null, className);
})
.then(done)
.catch(done); .catch(done);
}, },

View File

@ -62,29 +62,29 @@ export default {
fiscalDataButton: 'vn-left-menu a[ui-sref="client.card.fiscalData"]', fiscalDataButton: 'vn-left-menu a[ui-sref="client.card.fiscalData"]',
socialNameInput: `${components.vnTextfield}[name="socialName"]`, socialNameInput: `${components.vnTextfield}[name="socialName"]`,
fiscalIdInput: `${components.vnTextfield}[name="fi"]`, fiscalIdInput: `${components.vnTextfield}[name="fi"]`,
equalizationTaxCheckbox: 'vn-check[label="Is equalizated"] md-checkbox', equalizationTaxCheckbox: 'vn-check[label="Is equalizated"]',
acceptPropagationButton: 'vn-client-fiscal-data > vn-confirm button[response=ACCEPT]', acceptPropagationButton: 'vn-client-fiscal-data > vn-confirm button[response=ACCEPT]',
addressInput: `${components.vnTextfield}[name="street"]`, addressInput: `${components.vnTextfield}[name="street"]`,
postcodeInput: `${components.vnTextfield}[name="postcode"]`, postcodeInput: `${components.vnTextfield}[name="postcode"]`,
cityInput: `${components.vnTextfield}[name="city"]`, cityInput: `${components.vnTextfield}[name="city"]`,
provinceAutocomplete: 'vn-autocomplete[field="$ctrl.client.provinceFk"]', provinceAutocomplete: 'vn-autocomplete[field="$ctrl.client.provinceFk"]',
countryAutocomplete: 'vn-autocomplete[field="$ctrl.client.countryFk"]', countryAutocomplete: 'vn-autocomplete[field="$ctrl.client.countryFk"]',
activeCheckbox: 'vn-check[label="Active"] md-checkbox', activeCheckbox: 'vn-check[label="Active"]',
frozenCheckbox: 'vn-check[label="Frozen"] md-checkbox', frozenCheckbox: 'vn-check[label="Frozen"]',
invoiceByAddressCheckbox: 'vn-check[label="Invoice by address"] md-checkbox', invoiceByAddressCheckbox: 'vn-check[label="Invoice by address"]',
verifiedDataCheckbox: 'vn-check[label="Verified data"] md-checkbox', verifiedDataCheckbox: 'vn-check[label="Verified data"]',
hasToInvoiceCheckbox: 'vn-check[label="Has to invoice"] md-checkbox', hasToInvoiceCheckbox: 'vn-check[label="Has to invoice"]',
invoiceByMailCheckbox: 'vn-check[label="Invoice by mail"] md-checkbox', invoiceByMailCheckbox: 'vn-check[label="Invoice by mail"]',
viesCheckbox: 'vn-check[label="Vies"] md-checkbox', viesCheckbox: 'vn-check[label="Vies"]',
saveButton: `${components.vnSubmit}` saveButton: `${components.vnSubmit}`
}, },
clientBillingData: { clientBillingData: {
payMethodAutocomplete: 'vn-autocomplete[field="$ctrl.client.payMethodFk"]', payMethodAutocomplete: 'vn-autocomplete[field="$ctrl.client.payMethodFk"]',
IBANInput: `${components.vnTextfield}[name="iban"]`, IBANInput: `${components.vnTextfield}[name="iban"]`,
dueDayInput: `${components.vnInputNumber}[name="dueDay"]`, dueDayInput: `${components.vnInputNumber}[name="dueDay"]`,
receivedCoreLCRCheckbox: 'vn-check[label="Received LCR"] md-checkbox', receivedCoreLCRCheckbox: 'vn-check[label="Received LCR"]',
receivedCoreVNLCheckbox: 'vn-check[label="Received core VNL"] md-checkbox', receivedCoreVNLCheckbox: 'vn-check[label="Received core VNL"]',
receivedB2BVNLCheckbox: 'vn-check[label="Received B2B VNL"] md-checkbox', receivedB2BVNLCheckbox: 'vn-check[label="Received B2B VNL"]',
swiftBicAutocomplete: 'vn-client-billing-data vn-autocomplete[field="$ctrl.client.bankEntityFk"]', swiftBicAutocomplete: 'vn-client-billing-data vn-autocomplete[field="$ctrl.client.bankEntityFk"]',
clearswiftBicButton: 'vn-client-billing-data vn-autocomplete[field="$ctrl.client.bankEntityFk"] > div > div > div > vn-icon > i', clearswiftBicButton: 'vn-client-billing-data vn-autocomplete[field="$ctrl.client.bankEntityFk"] > div > div > div > vn-icon > i',
newBankEntityButton: 'vn-client-billing-data vn-icon-button[vn-tooltip="New bank entity"] > button', newBankEntityButton: 'vn-client-billing-data vn-icon-button[vn-tooltip="New bank entity"] > button',
@ -97,7 +97,7 @@ export default {
clientAddresses: { clientAddresses: {
addressesButton: 'vn-left-menu a[ui-sref="client.card.address.index"]', addressesButton: 'vn-left-menu a[ui-sref="client.card.address.index"]',
createAddress: `vn-client-address-index ${components.vnFloatButton}`, createAddress: `vn-client-address-index ${components.vnFloatButton}`,
defaultCheckboxInput: 'vn-check[label="Default"] md-checkbox', defaultCheckboxInput: 'vn-check[label="Default"]',
consigneeInput: `${components.vnTextfield}[name="nickname"]`, consigneeInput: `${components.vnTextfield}[name="nickname"]`,
streetAddressInput: `${components.vnTextfield}[name="street"]`, streetAddressInput: `${components.vnTextfield}[name="street"]`,
postcodeInput: `${components.vnTextfield}[name="postalCode"]`, postcodeInput: `${components.vnTextfield}[name="postalCode"]`,
@ -110,8 +110,8 @@ export default {
secondMakeDefaultStar: 'vn-client-address-index vn-card div:nth-child(2) vn-icon-button[icon="star_border"]', secondMakeDefaultStar: 'vn-client-address-index vn-card div:nth-child(2) vn-icon-button[icon="star_border"]',
firstEditAddress: 'vn-client-address-index div:nth-child(1) > a', firstEditAddress: 'vn-client-address-index div:nth-child(1) > a',
secondEditAddress: 'vn-client-address-index div:nth-child(2) > a', secondEditAddress: 'vn-client-address-index div:nth-child(2) > a',
activeCheckbox: 'vn-check[label="Enabled"] md-checkbox', activeCheckbox: 'vn-check[label="Enabled"]',
equalizationTaxCheckbox: 'vn-client-address-edit vn-check[label="Is equalizated"] md-checkbox', equalizationTaxCheckbox: 'vn-client-address-edit vn-check[label="Is equalizated"]',
firstObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] :nth-child(1) [field="observation.observationTypeFk"]', firstObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] :nth-child(1) [field="observation.observationTypeFk"]',
firstObservationDescriptionInput: 'vn-client-address-edit [name=observations] :nth-child(1) [model="observation.description"] input', firstObservationDescriptionInput: 'vn-client-address-edit [name=observations] :nth-child(1) [model="observation.description"] input',
secondObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] :nth-child(2) [field="observation.observationTypeFk"]', secondObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] :nth-child(2) [field="observation.observationTypeFk"]',
@ -123,7 +123,7 @@ export default {
}, },
clientWebAccess: { clientWebAccess: {
webAccessButton: 'vn-left-menu a[ui-sref="client.card.webAccess"]', webAccessButton: 'vn-left-menu a[ui-sref="client.card.webAccess"]',
enableWebAccessCheckbox: 'vn-check[label="Enable web access"] md-checkbox', enableWebAccessCheckbox: 'vn-check[label="Enable web access"]',
userNameInput: `${components.vnTextfield}[name="name"]`, userNameInput: `${components.vnTextfield}[name="name"]`,
saveButton: `${components.vnSubmit}` saveButton: `${components.vnSubmit}`
}, },
@ -172,7 +172,7 @@ export default {
}, },
webPayment: { webPayment: {
confirmFirstPaymentButton: 'vn-client-web-payment vn-tr:nth-child(1) vn-icon-button[icon="done_all"]', confirmFirstPaymentButton: 'vn-client-web-payment vn-tr:nth-child(1) vn-icon-button[icon="done_all"]',
firstPaymentConfirmed: 'vn-client-web-payment vn-tr:nth-child(1) vn-icon[icon="check"][aria-hidden="false"]' firstPaymentConfirmed: 'vn-client-web-payment vn-tr:nth-child(1) vn-icon[icon="check"]'
}, },
dms: { dms: {
deleteFileButton: 'vn-client-dms-index vn-table vn-tr:nth-child(1) vn-icon-button[icon="delete"]', deleteFileButton: 'vn-client-dms-index vn-table vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
@ -194,17 +194,17 @@ export default {
fieldsToShowForm: 'vn-item-index > div > vn-card > div > vn-table > div.ng-scope > div > vn-dialog > div > form', fieldsToShowForm: 'vn-item-index > div > vn-card > div > vn-table > div.ng-scope > div > vn-dialog > div > form',
firstItemImage: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(1)', firstItemImage: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(1)',
firstItemId: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(2)', firstItemId: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(2)',
idCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(2) > vn-check > md-checkbox', idCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(2) > vn-check',
stemsCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(3) > vn-check > md-checkbox', stemsCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(3) > vn-check',
sizeCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(4) > vn-check > md-checkbox', sizeCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(4) > vn-check',
nicheCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(5) > vn-check > md-checkbox', nicheCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(5) > vn-check',
typeCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(6) > vn-check > md-checkbox', typeCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(6) > vn-check',
categoryCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(7) > vn-check > md-checkbox', categoryCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(7) > vn-check',
intrastadCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(8) > vn-check > md-checkbox', intrastadCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(8) > vn-check',
originCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(9) > vn-check > md-checkbox', originCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(9) > vn-check',
buyerCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(10) > vn-check > md-checkbox', buyerCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(10) > vn-check',
destinyCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(11) > vn-check > md-checkbox', destinyCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(11) > vn-check',
taxClassCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(12) > vn-check > md-checkbox', taxClassCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(12) > vn-check',
saveFieldsButton: 'vn-item-index vn-dialog vn-horizontal:nth-child(16) > vn-button > button' saveFieldsButton: 'vn-item-index vn-dialog vn-horizontal:nth-child(16) > vn-button > button'
}, },
itemCreateView: { itemCreateView: {
@ -236,8 +236,8 @@ export default {
originAutocomplete: 'vn-autocomplete[field="$ctrl.item.originFk"]', originAutocomplete: 'vn-autocomplete[field="$ctrl.item.originFk"]',
expenceAutocomplete: 'vn-autocomplete[field="$ctrl.item.expenceFk"]', expenceAutocomplete: 'vn-autocomplete[field="$ctrl.item.expenceFk"]',
longNameInput: 'vn-textfield[field="$ctrl.item.longName"] input', longNameInput: 'vn-textfield[field="$ctrl.item.longName"] input',
isActiveCheckbox: 'vn-check[label="Active"] md-checkbox', isActiveCheckbox: 'vn-check[label="Active"]',
priceInKgCheckbox: 'vn-check[label="Price in kg"] md-checkbox', priceInKgCheckbox: 'vn-check[label="Price in kg"]',
submitBasicDataButton: `${components.vnSubmit}` submitBasicDataButton: `${components.vnSubmit}`
}, },
itemTags: { itemTags: {
@ -430,7 +430,7 @@ export default {
firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(3)', firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(3)',
firstSaleColour: 'vn-tr:nth-child(1) vn-fetched-tags section', firstSaleColour: 'vn-tr:nth-child(1) vn-fetched-tags section',
firstSaleLength: 'vn-ticket-sale vn-tr:nth-child(1) vn-td-editable:nth-child(6) section:nth-child(3)', firstSaleLength: 'vn-ticket-sale vn-tr:nth-child(1) vn-td-editable:nth-child(6) section:nth-child(3)',
firstSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(1) vn-check[field="sale.checked"] md-checkbox', firstSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(1) vn-check[field="sale.checked"]',
secondSaleColour: 'vn-tr:nth-child(2) vn-fetched-tags section', secondSaleColour: 'vn-tr:nth-child(2) vn-fetched-tags section',
secondSalePrice: 'vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(7) > span', secondSalePrice: 'vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(7) > span',
secondSaleDiscount: 'vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(8)', secondSaleDiscount: 'vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(8)',
@ -444,9 +444,9 @@ export default {
secondSaleConceptCell: 'vn-ticket-sale vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(6)', secondSaleConceptCell: 'vn-ticket-sale vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(6)',
secondSaleConceptInput: 'vn-ticket-sale vn-table vn-tr:nth-child(2) > vn-td-editable.ng-isolate-scope.selected vn-textfield input', secondSaleConceptInput: 'vn-ticket-sale vn-table vn-tr:nth-child(2) > vn-td-editable.ng-isolate-scope.selected vn-textfield input',
totalImport: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-horizontal > vn-one > p:nth-child(3) > strong', totalImport: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-horizontal > vn-one > p:nth-child(3) > strong',
selectAllSalesCheckbox: 'vn-ticket-sale vn-thead vn-check md-checkbox', selectAllSalesCheckbox: 'vn-ticket-sale vn-thead vn-check',
secondSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(2) vn-check[field="sale.checked"] md-checkbox', secondSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(2) vn-check[field="sale.checked"]',
thirdSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(3) vn-check[field="sale.checked"] md-checkbox', thirdSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(3) vn-check[field="sale.checked"]',
deleteSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="delete"]', deleteSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="delete"]',
transferSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="call_split"]', transferSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="call_split"]',
moveToTicketInput: '.vn-popover.shown vn-textfield[model="$ctrl.transfer.ticketId"] input', moveToTicketInput: '.vn-popover.shown vn-textfield[model="$ctrl.transfer.ticketId"] input',
@ -579,7 +579,7 @@ export default {
firstLineDestination: 'vn-claim-action vn-tr:nth-child(1) vn-autocomplete[field="saleClaimed.claimDestinationFk"]', firstLineDestination: 'vn-claim-action vn-tr:nth-child(1) vn-autocomplete[field="saleClaimed.claimDestinationFk"]',
secondLineDestination: 'vn-claim-action vn-tr:nth-child(2) vn-autocomplete[field="saleClaimed.claimDestinationFk"]', secondLineDestination: 'vn-claim-action vn-tr:nth-child(2) vn-autocomplete[field="saleClaimed.claimDestinationFk"]',
firstDeleteLine: 'vn-claim-action vn-tr:nth-child(1) vn-icon-button[icon="delete"]', firstDeleteLine: 'vn-claim-action vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
isPaidWithManaCheckbox: 'vn-check[field="$ctrl.claim.isChargedToMana"] md-checkbox' isPaidWithManaCheckbox: 'vn-check[field="$ctrl.claim.isChargedToMana"]'
}, },
ordersIndex: { ordersIndex: {
searchResult: 'vn-order-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr', searchResult: 'vn-order-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr',
@ -662,7 +662,7 @@ export default {
thirdTicketPriority: 'vn-route-tickets vn-tr:nth-child(3) vn-textfield[model="ticket.priority"] input', thirdTicketPriority: 'vn-route-tickets vn-tr:nth-child(3) vn-textfield[model="ticket.priority"] input',
fourthTicketPriority: 'vn-route-tickets vn-tr:nth-child(4) vn-textfield[model="ticket.priority"] input', fourthTicketPriority: 'vn-route-tickets vn-tr:nth-child(4) vn-textfield[model="ticket.priority"] input',
eleventhTicketPriority: 'vn-route-tickets vn-tr:nth-child(11) vn-textfield[model="ticket.priority"] input', eleventhTicketPriority: 'vn-route-tickets vn-tr:nth-child(11) vn-textfield[model="ticket.priority"] input',
firstTicketCheckbox: 'vn-route-tickets vn-tr:nth-child(1) vn-check md-checkbox', firstTicketCheckbox: 'vn-route-tickets vn-tr:nth-child(1) vn-check',
buscamanButton: 'vn-route-tickets vn-button[icon="icon-buscaman"]', buscamanButton: 'vn-route-tickets vn-button[icon="icon-buscaman"]',
firstTicketDeleteButton: 'vn-route-tickets vn-tr:nth-child(1) vn-icon[icon="delete"]', firstTicketDeleteButton: 'vn-route-tickets vn-tr:nth-child(1) vn-icon[icon="delete"]',
confirmButton: 'vn-route-tickets > vn-confirm button[response="ACCEPT"]' confirmButton: 'vn-route-tickets > vn-confirm button[response="ACCEPT"]'

View File

@ -53,10 +53,7 @@ describe('Client lock verified data path', () => {
it('should confirm verified data button is enabled for administrative', async() => { it('should confirm verified data button is enabled for administrative', async() => {
const result = await nightmare const result = await nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckbox) .isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
@ -107,13 +104,10 @@ describe('Client lock verified data path', () => {
}); });
it('should confirm verified data button is disabled once again for salesPerson', async() => { it('should confirm verified data button is disabled once again for salesPerson', async() => {
const isChecked = await nightmare const isDisabled = await nightmare
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked') .isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
.evaluate(selector => {
return document.querySelector(selector).getAttribute('disabled');
}, selectors.clientFiscalData.verifiedDataCheckbox);
expect(isChecked).toBeTruthy(); expect(isDisabled).toBeTruthy();
}); });
it('should not be able to save change throwing a verified data error', async() => { it('should not be able to save change throwing a verified data error', async() => {
@ -138,12 +132,9 @@ describe('Client lock verified data path', () => {
it('should confirm verified data button is enabled for salesAssistant', async() => { it('should confirm verified data button is enabled for salesAssistant', async() => {
const isDisabled = await nightmare const isDisabled = await nightmare
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked') .isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
.evaluate(selector => {
return document.querySelector(selector).getAttribute('aria-disabled');
}, selectors.clientFiscalData.verifiedDataCheckbox);
expect(isDisabled).toEqual('false'); expect(isDisabled).toBeFalsy();
}); });
it('should now edit the social name', async() => { it('should now edit the social name', async() => {
@ -174,13 +165,10 @@ describe('Client lock verified data path', () => {
}); });
it('should confirm verified data button is enabled once again', async() => { it('should confirm verified data button is enabled once again', async() => {
const isChecked = await nightmare const isDisabled = await nightmare
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked') .isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
.evaluate(selector => {
return document.querySelector(selector).getAttribute('disabled');
}, selectors.clientFiscalData.verifiedDataCheckbox);
expect(isChecked).toBeTruthy(); expect(isDisabled).toBeTruthy();
}); });
it('should confirm the form is enabled for salesPerson', async() => { it('should confirm the form is enabled for salesPerson', async() => {

View File

@ -1,11 +1,10 @@
<md-checkbox <div class="check">
aria-label="::$ctrl.label" <div class="focus"></div>
md-indeterminate="$ctrl.isIntermediate" <div class="mark"></div>
ng-disabled="::$ctrl.disabled" </div>
ng-checked="$ctrl.isChecked" <span translate>
ng-model="$ctrl.model"> {{::$ctrl.label}}
<span translate ng-if="::$ctrl.label">{{::$ctrl.label}}</span> </span>
</md-checkbox>
<i class="material-icons" <i class="material-icons"
ng-if="::$ctrl.hasInfo" ng-if="::$ctrl.hasInfo"
vn-tooltip="{{::$ctrl.info}}"> vn-tooltip="{{::$ctrl.info}}">

View File

@ -3,47 +3,71 @@ import Component from '../../lib/component';
import './style.scss'; import './style.scss';
export default class Controller extends Component { export default class Controller extends Component {
constructor($element, $scope, $attrs) { constructor($element, $, $attrs) {
super($element, $scope); super($element, $);
this.hasInfo = Boolean($attrs.info); this.hasInfo = Boolean($attrs.info);
this.info = $attrs.info || null; this.info = $attrs.info || null;
}
get model() { let element = this.element;
return this._model; element.addEventListener('click', e => this.onClick(e));
} element.addEventListener('keydown', e => this.onClick(e));
element.tabIndex = 0;
set model(value) { this.check = element.querySelector('.check');
if (value === null) return;
if (this.model === false && this.tripleState)
value = null;
this.emit('change', {value});
this._model = value;
} }
set field(value) { set field(value) {
if (typeof value === 'number') this._field = value;
value = Boolean(value); let isIndeterminate = Boolean(value == null && this.tripleState);
this.check.classList.toggle('checked', Boolean(value));
this._model = value; this.check.classList.toggle('indeterminate', isIndeterminate);
} }
get field() { get field() {
return this._model; return this._field;
} }
get isIntermediate() { set disabled(value) {
if (this.intermediate || (this.tripleState && (this.model === null || this.model === undefined))) this.element.tabIndex = !value ? 0 : -1;
return true; this.check.classList.toggle('disabled', Boolean(value));
this._disabled = value;
return false;
} }
get isChecked() { get disabled() {
return this.checked || this.model === true; return this._disabled;
}
set tripleState(value) {
this._tripleState = value;
this.field = this.field;
}
get tripleState() {
return this._tripleState;
}
onClick(event) {
event.preventDefault();
if (this.disabled) return;
if (this.tripleState) {
if (this.field == null)
this.field = false;
else if (!this.field)
this.field = true;
else
this.field = null;
} else
this.field = !this.field;
this.$.$applyAsync();
this.element.dispatchEvent(new Event('change'));
}
onKeydown(event) {
if (event.code == 'Space')
this.onClick(event);
} }
} }

View File

@ -1,6 +1,7 @@
describe('Component vnCheck', () => { describe('Component vnCheck', () => {
let controller;
let $element; let $element;
let $ctrl;
let element;
beforeEach(angular.mock.module('vnCore', $translateProvider => { beforeEach(angular.mock.module('vnCore', $translateProvider => {
$translateProvider.translations('en', {}); $translateProvider.translations('en', {});
@ -8,59 +9,56 @@ describe('Component vnCheck', () => {
beforeEach(inject(($compile, $rootScope) => { beforeEach(inject(($compile, $rootScope) => {
$element = $compile(`<vn-check></vn-check`)($rootScope); $element = $compile(`<vn-check></vn-check`)($rootScope);
controller = $element.controller('vnCheck'); $ctrl = $element.controller('vnCheck');
element = $element[0];
})); }));
afterEach(() => { afterEach(() => {
$element.remove(); $element.remove();
}); });
describe('model() setter', () => {
it(`should set model value`, () => {
controller.model = true;
expect(controller.model).toEqual(true);
});
it(`should set model value to null if current model value is false and is a triple-state checkbox`, () => {
controller._model = false;
controller.tripleState = true;
controller.model = true;
expect(controller.model).toEqual(null);
});
});
describe('field() setter', () => { describe('field() setter', () => {
it(`should set model value`, () => { it(`should set model value`, () => {
controller.field = true; $ctrl.field = true;
expect(controller.field).toEqual(true); expect($ctrl.field).toEqual(true);
}); });
it(`should set model value and convert numerical values to boolean values`, () => { it(`should uncheck value and change to true when clicked`, () => {
controller.field = 1; $ctrl.field = false;
element.click();
expect(controller.field).toEqual(true); expect($ctrl.field).toEqual(true);
});
}); });
describe('isIntermediate() getter', () => { it(`should check value and change to false when clicked`, () => {
it(`should return true if intermediate property is truthy`, () => { $ctrl.field = true;
controller.intermediate = true; element.click();
let result = controller.isIntermediate; expect($ctrl.field).toEqual(false);
expect(result).toEqual(true);
}); });
it(`should return true if is a triple-state checkbox and has null or undefined value`, () => { it(`should check value and change to null when clicked`, () => {
controller.tripleState = true; $ctrl.field = true;
controller.model = null; $ctrl.tripleState = true;
element.click();
let result = controller.isIntermediate; expect($ctrl.field).toEqual(null);
});
expect(result).toEqual(true); it(`should set value to null and change to false when clicked`, () => {
$ctrl.field = null;
$ctrl.tripleState = true;
element.click();
expect($ctrl.field).toEqual(false);
});
it(`should cast value to boolean when clicked`, () => {
$ctrl.field = 0;
element.click();
expect($ctrl.field).toEqual(true);
}); });
}); });
}); });

View File

@ -2,24 +2,77 @@
vn-check { vn-check {
position: relative; position: relative;
cursor: pointer;
display: inline-block;
outline: none;
& > .check {
position: relative;
box-sizing: border-box;
display: inline-block;
vertical-align: middle;
border-radius: 2px;
width: 20px;
height: 20px;
transition: background 250ms;
border: 2px solid #666;
margin: 3px;
margin-right: .4em;
& > .mark {
box-sizing: border-box;
position: absolute;
display: block;
border-width: 0;
}
&.checked {
background-color: $color-main;
border-color: $color-main;
& > .focus {
background-color: rgba($color-main, .15);
}
}
&.checked > .mark {
top: 0;
left: 4px;
transform: rotate(45deg);
width: 7px;
height: 13px;
border: 2px solid $color-font-dark;
border-top: 0;
border-left: 0;
}
&.indeterminate > .mark {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 12px;
height: 2px;
border-bottom: 2px solid #666;
}
}
& > .check > .focus {
position: absolute;
top: 50%;
left: 50%;
height: 38px;
width: 38px;
margin-top: -19px;
margin-left: -19px;
border-radius: 50%;
transform: scale3d(0, 0, 0);
transition: background 250ms;
transition: transform 250ms;
background-color: rgba(0, 0, 0, .1);
}
&:focus > .check:not(.disabled) > .focus {
transform: scale3d(1, 1, 1);
}
& > i { & > i {
padding-left: 5px; padding-left: 5px;
position: absolute; position: absolute;
color: $color-font-secondary; color: $color-font-secondary;
font-size: 20px !important; font-size: 20px;
cursor: help
}
md-checkbox.md-checked .md-icon {
background-color: $color-main;
}
md-checkbox {
margin-bottom: 0.8em;
.md-label:empty {
margin: 0
}
} }
} }

View File

@ -13,6 +13,7 @@ vn-icon-button {
color: inherit; color: inherit;
border: 0; border: 0;
padding: 0; padding: 0;
font-size: inherit;
&:hover { &:hover {
background-color: initial; background-color: initial;

View File

@ -7,8 +7,10 @@ import 'angular-translate-loader-partial';
import '@uirouter/angularjs'; import '@uirouter/angularjs';
import 'mg-crud'; import 'mg-crud';
import 'oclazyload'; import 'oclazyload';
/*
import 'angular-material'; import 'angular-material';
import 'angular-material/modules/scss/angular-material.scss'; import 'angular-material/modules/scss/angular-material.scss';
*/
import 'angular-moment'; import 'angular-moment';
export const ngDeps = [ export const ngDeps = [
@ -16,7 +18,7 @@ export const ngDeps = [
'ui.router', 'ui.router',
'mgCrud', 'mgCrud',
'oc.lazyLoad', 'oc.lazyLoad',
'ngMaterial', // 'ngMaterial',
'angularMoment' 'angularMoment'
]; ];

534
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,6 @@
"angular": "^1.7.5", "angular": "^1.7.5",
"angular-animate": "^1.7.7", "angular-animate": "^1.7.7",
"angular-aria": "^1.7.7", "angular-aria": "^1.7.7",
"angular-material": "^1.1.12",
"angular-moment": "^1.3.0", "angular-moment": "^1.3.0",
"angular-translate": "^2.18.1", "angular-translate": "^2.18.1",
"angular-translate-loader-partial": "^2.18.1", "angular-translate-loader-partial": "^2.18.1",
@ -24,7 +23,7 @@
"material-design-lite": "^1.3.0", "material-design-lite": "^1.3.0",
"mg-crud": "^1.1.2", "mg-crud": "^1.1.2",
"moment-timezone": "^0.5.25", "moment-timezone": "^0.5.25",
"npm": "^6.9.0", "npm": "^6.11.3",
"oclazyload": "^0.6.3", "oclazyload": "^0.6.3",
"require-yaml": "0.0.1", "require-yaml": "0.0.1",
"validator": "^6.3.0" "validator": "^6.3.0"

View File

@ -236,7 +236,6 @@ class Controller {
addTime(response) { addTime(response) {
if (response === 'ACCEPT') { if (response === 'ACCEPT') {
console.log('newTime', this.newTime);
let data = {workerFk: this.worker.id, timed: this.newTime}; let data = {workerFk: this.worker.id, timed: this.newTime};
let query = `/api/WorkerTimeControls/addTime`; let query = `/api/WorkerTimeControls/addTime`;
this.$http.post(query, data).then(() => { this.$http.post(query, data).then(() => {