#1297 Angular material removed from project
This commit is contained in:
parent
80e1f5d476
commit
679c6af0df
|
@ -483,26 +483,28 @@ let actions = {
|
|||
|
||||
checkboxState: function(selector, done) {
|
||||
this.wait(selector)
|
||||
.evaluate(checkboxSelector => {
|
||||
return document.querySelector(checkboxSelector).getAttribute('class');
|
||||
.evaluate(selector => {
|
||||
let checkbox = document.querySelector(selector);
|
||||
switch (checkbox.$ctrl.field) {
|
||||
case null:
|
||||
return 'intermediate';
|
||||
case true:
|
||||
return 'checked';
|
||||
default:
|
||||
return 'unchecked';
|
||||
}
|
||||
}, selector)
|
||||
.then(elementClass => {
|
||||
let classList = elementClass.split(' ');
|
||||
let className;
|
||||
.then(res => done(null, res))
|
||||
.catch(done);
|
||||
},
|
||||
|
||||
if (classList.includes('md-checked'))
|
||||
className = 'checked';
|
||||
if (classList.includes('md-intermediate'))
|
||||
className = 'intermediate';
|
||||
if (!classList.includes('md-intermediate') && !classList.includes('md-checked'))
|
||||
className = 'unchecked';
|
||||
|
||||
if (!className)
|
||||
throw new Error(`selector: ${selector} is not a md-checkbox`);
|
||||
|
||||
done(null, className);
|
||||
})
|
||||
.then(done)
|
||||
isDisabled: function(selector, done) {
|
||||
this.wait(selector)
|
||||
.evaluate(selector => {
|
||||
let element = document.querySelector(selector);
|
||||
return element.$ctrl.disabled;
|
||||
}, selector)
|
||||
.then(res => done(null, res))
|
||||
.catch(done);
|
||||
},
|
||||
|
||||
|
|
|
@ -62,29 +62,29 @@ export default {
|
|||
fiscalDataButton: 'vn-left-menu a[ui-sref="client.card.fiscalData"]',
|
||||
socialNameInput: `${components.vnTextfield}[name="socialName"]`,
|
||||
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]',
|
||||
addressInput: `${components.vnTextfield}[name="street"]`,
|
||||
postcodeInput: `${components.vnTextfield}[name="postcode"]`,
|
||||
cityInput: `${components.vnTextfield}[name="city"]`,
|
||||
provinceAutocomplete: 'vn-autocomplete[field="$ctrl.client.provinceFk"]',
|
||||
countryAutocomplete: 'vn-autocomplete[field="$ctrl.client.countryFk"]',
|
||||
activeCheckbox: 'vn-check[label="Active"] md-checkbox',
|
||||
frozenCheckbox: 'vn-check[label="Frozen"] md-checkbox',
|
||||
invoiceByAddressCheckbox: 'vn-check[label="Invoice by address"] md-checkbox',
|
||||
verifiedDataCheckbox: 'vn-check[label="Verified data"] md-checkbox',
|
||||
hasToInvoiceCheckbox: 'vn-check[label="Has to invoice"] md-checkbox',
|
||||
invoiceByMailCheckbox: 'vn-check[label="Invoice by mail"] md-checkbox',
|
||||
viesCheckbox: 'vn-check[label="Vies"] md-checkbox',
|
||||
activeCheckbox: 'vn-check[label="Active"]',
|
||||
frozenCheckbox: 'vn-check[label="Frozen"]',
|
||||
invoiceByAddressCheckbox: 'vn-check[label="Invoice by address"]',
|
||||
verifiedDataCheckbox: 'vn-check[label="Verified data"]',
|
||||
hasToInvoiceCheckbox: 'vn-check[label="Has to invoice"]',
|
||||
invoiceByMailCheckbox: 'vn-check[label="Invoice by mail"]',
|
||||
viesCheckbox: 'vn-check[label="Vies"]',
|
||||
saveButton: `${components.vnSubmit}`
|
||||
},
|
||||
clientBillingData: {
|
||||
payMethodAutocomplete: 'vn-autocomplete[field="$ctrl.client.payMethodFk"]',
|
||||
IBANInput: `${components.vnTextfield}[name="iban"]`,
|
||||
dueDayInput: `${components.vnInputNumber}[name="dueDay"]`,
|
||||
receivedCoreLCRCheckbox: 'vn-check[label="Received LCR"] md-checkbox',
|
||||
receivedCoreVNLCheckbox: 'vn-check[label="Received core VNL"] md-checkbox',
|
||||
receivedB2BVNLCheckbox: 'vn-check[label="Received B2B VNL"] md-checkbox',
|
||||
receivedCoreLCRCheckbox: 'vn-check[label="Received LCR"]',
|
||||
receivedCoreVNLCheckbox: 'vn-check[label="Received core VNL"]',
|
||||
receivedB2BVNLCheckbox: 'vn-check[label="Received B2B VNL"]',
|
||||
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',
|
||||
newBankEntityButton: 'vn-client-billing-data vn-icon-button[vn-tooltip="New bank entity"] > button',
|
||||
|
@ -97,7 +97,7 @@ export default {
|
|||
clientAddresses: {
|
||||
addressesButton: 'vn-left-menu a[ui-sref="client.card.address.index"]',
|
||||
createAddress: `vn-client-address-index ${components.vnFloatButton}`,
|
||||
defaultCheckboxInput: 'vn-check[label="Default"] md-checkbox',
|
||||
defaultCheckboxInput: 'vn-check[label="Default"]',
|
||||
consigneeInput: `${components.vnTextfield}[name="nickname"]`,
|
||||
streetAddressInput: `${components.vnTextfield}[name="street"]`,
|
||||
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"]',
|
||||
firstEditAddress: 'vn-client-address-index div:nth-child(1) > a',
|
||||
secondEditAddress: 'vn-client-address-index div:nth-child(2) > a',
|
||||
activeCheckbox: 'vn-check[label="Enabled"] md-checkbox',
|
||||
equalizationTaxCheckbox: 'vn-client-address-edit vn-check[label="Is equalizated"] md-checkbox',
|
||||
activeCheckbox: 'vn-check[label="Enabled"]',
|
||||
equalizationTaxCheckbox: 'vn-client-address-edit vn-check[label="Is equalizated"]',
|
||||
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',
|
||||
secondObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] :nth-child(2) [field="observation.observationTypeFk"]',
|
||||
|
@ -123,7 +123,7 @@ export default {
|
|||
},
|
||||
clientWebAccess: {
|
||||
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"]`,
|
||||
saveButton: `${components.vnSubmit}`
|
||||
},
|
||||
|
@ -172,7 +172,7 @@ export default {
|
|||
},
|
||||
webPayment: {
|
||||
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: {
|
||||
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',
|
||||
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)',
|
||||
idCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(2) > vn-check > md-checkbox',
|
||||
stemsCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(3) > vn-check > md-checkbox',
|
||||
sizeCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(4) > vn-check > md-checkbox',
|
||||
nicheCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(5) > vn-check > md-checkbox',
|
||||
typeCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(6) > vn-check > md-checkbox',
|
||||
categoryCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(7) > vn-check > md-checkbox',
|
||||
intrastadCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(8) > vn-check > md-checkbox',
|
||||
originCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(9) > vn-check > md-checkbox',
|
||||
buyerCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(10) > vn-check > md-checkbox',
|
||||
destinyCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(11) > vn-check > md-checkbox',
|
||||
taxClassCheckbox: 'vn-item-index vn-dialog form vn-horizontal:nth-child(12) > 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',
|
||||
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',
|
||||
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',
|
||||
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',
|
||||
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',
|
||||
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'
|
||||
},
|
||||
itemCreateView: {
|
||||
|
@ -236,8 +236,8 @@ export default {
|
|||
originAutocomplete: 'vn-autocomplete[field="$ctrl.item.originFk"]',
|
||||
expenceAutocomplete: 'vn-autocomplete[field="$ctrl.item.expenceFk"]',
|
||||
longNameInput: 'vn-textfield[field="$ctrl.item.longName"] input',
|
||||
isActiveCheckbox: 'vn-check[label="Active"] md-checkbox',
|
||||
priceInKgCheckbox: 'vn-check[label="Price in kg"] md-checkbox',
|
||||
isActiveCheckbox: 'vn-check[label="Active"]',
|
||||
priceInKgCheckbox: 'vn-check[label="Price in kg"]',
|
||||
submitBasicDataButton: `${components.vnSubmit}`
|
||||
},
|
||||
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)',
|
||||
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)',
|
||||
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',
|
||||
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)',
|
||||
|
@ -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)',
|
||||
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',
|
||||
selectAllSalesCheckbox: 'vn-ticket-sale vn-thead vn-check md-checkbox',
|
||||
secondSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(2) vn-check[field="sale.checked"] md-checkbox',
|
||||
thirdSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(3) vn-check[field="sale.checked"] md-checkbox',
|
||||
selectAllSalesCheckbox: 'vn-ticket-sale vn-thead vn-check',
|
||||
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"]',
|
||||
deleteSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="delete"]',
|
||||
transferSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="call_split"]',
|
||||
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"]',
|
||||
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"]',
|
||||
isPaidWithManaCheckbox: 'vn-check[field="$ctrl.claim.isChargedToMana"] md-checkbox'
|
||||
isPaidWithManaCheckbox: 'vn-check[field="$ctrl.claim.isChargedToMana"]'
|
||||
},
|
||||
ordersIndex: {
|
||||
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',
|
||||
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',
|
||||
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"]',
|
||||
firstTicketDeleteButton: 'vn-route-tickets vn-tr:nth-child(1) vn-icon[icon="delete"]',
|
||||
confirmButton: 'vn-route-tickets > vn-confirm button[response="ACCEPT"]'
|
||||
|
|
|
@ -53,10 +53,7 @@ describe('Client lock verified data path', () => {
|
|||
|
||||
it('should confirm verified data button is enabled for administrative', async() => {
|
||||
const result = await nightmare
|
||||
.wait(selectors.clientFiscalData.verifiedDataCheckbox)
|
||||
.evaluate(selector => {
|
||||
return document.querySelector(selector).disabled;
|
||||
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
||||
.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
|
||||
|
||||
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() => {
|
||||
const isChecked = await nightmare
|
||||
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
|
||||
.evaluate(selector => {
|
||||
return document.querySelector(selector).getAttribute('disabled');
|
||||
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
||||
const isDisabled = await nightmare
|
||||
.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
|
||||
|
||||
expect(isChecked).toBeTruthy();
|
||||
expect(isDisabled).toBeTruthy();
|
||||
});
|
||||
|
||||
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() => {
|
||||
const isDisabled = await nightmare
|
||||
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
|
||||
.evaluate(selector => {
|
||||
return document.querySelector(selector).getAttribute('aria-disabled');
|
||||
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
||||
.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
|
||||
|
||||
expect(isDisabled).toEqual('false');
|
||||
expect(isDisabled).toBeFalsy();
|
||||
});
|
||||
|
||||
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() => {
|
||||
const isChecked = await nightmare
|
||||
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
|
||||
.evaluate(selector => {
|
||||
return document.querySelector(selector).getAttribute('disabled');
|
||||
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
||||
const isDisabled = await nightmare
|
||||
.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
|
||||
|
||||
expect(isChecked).toBeTruthy();
|
||||
expect(isDisabled).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should confirm the form is enabled for salesPerson', async() => {
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<md-checkbox
|
||||
aria-label="::$ctrl.label"
|
||||
md-indeterminate="$ctrl.isIntermediate"
|
||||
ng-disabled="::$ctrl.disabled"
|
||||
ng-checked="$ctrl.isChecked"
|
||||
ng-model="$ctrl.model">
|
||||
<span translate ng-if="::$ctrl.label">{{::$ctrl.label}}</span>
|
||||
</md-checkbox>
|
||||
<div class="check">
|
||||
<div class="focus"></div>
|
||||
<div class="mark"></div>
|
||||
</div>
|
||||
<span translate>
|
||||
{{::$ctrl.label}}
|
||||
</span>
|
||||
<i class="material-icons"
|
||||
ng-if="::$ctrl.hasInfo"
|
||||
vn-tooltip="{{::$ctrl.info}}">
|
||||
|
|
|
@ -3,47 +3,71 @@ import Component from '../../lib/component';
|
|||
import './style.scss';
|
||||
|
||||
export default class Controller extends Component {
|
||||
constructor($element, $scope, $attrs) {
|
||||
super($element, $scope);
|
||||
constructor($element, $, $attrs) {
|
||||
super($element, $);
|
||||
this.hasInfo = Boolean($attrs.info);
|
||||
this.info = $attrs.info || null;
|
||||
}
|
||||
|
||||
get model() {
|
||||
return this._model;
|
||||
}
|
||||
let element = this.element;
|
||||
element.addEventListener('click', e => this.onClick(e));
|
||||
element.addEventListener('keydown', e => this.onClick(e));
|
||||
element.tabIndex = 0;
|
||||
|
||||
set model(value) {
|
||||
if (value === null) return;
|
||||
|
||||
if (this.model === false && this.tripleState)
|
||||
value = null;
|
||||
|
||||
this.emit('change', {value});
|
||||
|
||||
this._model = value;
|
||||
this.check = element.querySelector('.check');
|
||||
}
|
||||
|
||||
set field(value) {
|
||||
if (typeof value === 'number')
|
||||
value = Boolean(value);
|
||||
|
||||
this._model = value;
|
||||
this._field = value;
|
||||
let isIndeterminate = Boolean(value == null && this.tripleState);
|
||||
this.check.classList.toggle('checked', Boolean(value));
|
||||
this.check.classList.toggle('indeterminate', isIndeterminate);
|
||||
}
|
||||
|
||||
get field() {
|
||||
return this._model;
|
||||
return this._field;
|
||||
}
|
||||
|
||||
get isIntermediate() {
|
||||
if (this.intermediate || (this.tripleState && (this.model === null || this.model === undefined)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
set disabled(value) {
|
||||
this.element.tabIndex = !value ? 0 : -1;
|
||||
this.check.classList.toggle('disabled', Boolean(value));
|
||||
this._disabled = value;
|
||||
}
|
||||
|
||||
get isChecked() {
|
||||
return this.checked || this.model === true;
|
||||
get disabled() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
describe('Component vnCheck', () => {
|
||||
let controller;
|
||||
let $element;
|
||||
let $ctrl;
|
||||
let element;
|
||||
|
||||
beforeEach(angular.mock.module('vnCore', $translateProvider => {
|
||||
$translateProvider.translations('en', {});
|
||||
|
@ -8,59 +9,56 @@ describe('Component vnCheck', () => {
|
|||
|
||||
beforeEach(inject(($compile, $rootScope) => {
|
||||
$element = $compile(`<vn-check></vn-check`)($rootScope);
|
||||
controller = $element.controller('vnCheck');
|
||||
$ctrl = $element.controller('vnCheck');
|
||||
element = $element[0];
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
$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', () => {
|
||||
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`, () => {
|
||||
controller.field = 1;
|
||||
it(`should uncheck value and change to true when clicked`, () => {
|
||||
$ctrl.field = false;
|
||||
element.click();
|
||||
|
||||
expect(controller.field).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isIntermediate() getter', () => {
|
||||
it(`should return true if intermediate property is truthy`, () => {
|
||||
controller.intermediate = true;
|
||||
|
||||
let result = controller.isIntermediate;
|
||||
|
||||
expect(result).toEqual(true);
|
||||
expect($ctrl.field).toEqual(true);
|
||||
});
|
||||
|
||||
it(`should return true if is a triple-state checkbox and has null or undefined value`, () => {
|
||||
controller.tripleState = true;
|
||||
controller.model = null;
|
||||
it(`should check value and change to false when clicked`, () => {
|
||||
$ctrl.field = true;
|
||||
element.click();
|
||||
|
||||
let result = controller.isIntermediate;
|
||||
expect($ctrl.field).toEqual(false);
|
||||
});
|
||||
|
||||
expect(result).toEqual(true);
|
||||
it(`should check value and change to null when clicked`, () => {
|
||||
$ctrl.field = true;
|
||||
$ctrl.tripleState = true;
|
||||
element.click();
|
||||
|
||||
expect($ctrl.field).toEqual(null);
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,24 +2,77 @@
|
|||
|
||||
vn-check {
|
||||
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 {
|
||||
padding-left: 5px;
|
||||
position: absolute;
|
||||
color: $color-font-secondary;
|
||||
font-size: 20px !important;
|
||||
cursor: help
|
||||
}
|
||||
|
||||
md-checkbox.md-checked .md-icon {
|
||||
background-color: $color-main;
|
||||
}
|
||||
|
||||
md-checkbox {
|
||||
margin-bottom: 0.8em;
|
||||
|
||||
.md-label:empty {
|
||||
margin: 0
|
||||
}
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ vn-icon-button {
|
|||
color: inherit;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
font-size: inherit;
|
||||
|
||||
&:hover {
|
||||
background-color: initial;
|
||||
|
|
|
@ -7,8 +7,10 @@ import 'angular-translate-loader-partial';
|
|||
import '@uirouter/angularjs';
|
||||
import 'mg-crud';
|
||||
import 'oclazyload';
|
||||
/*
|
||||
import 'angular-material';
|
||||
import 'angular-material/modules/scss/angular-material.scss';
|
||||
*/
|
||||
import 'angular-moment';
|
||||
|
||||
export const ngDeps = [
|
||||
|
@ -16,7 +18,7 @@ export const ngDeps = [
|
|||
'ui.router',
|
||||
'mgCrud',
|
||||
'oc.lazyLoad',
|
||||
'ngMaterial',
|
||||
// 'ngMaterial',
|
||||
'angularMoment'
|
||||
];
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,7 +14,6 @@
|
|||
"angular": "^1.7.5",
|
||||
"angular-animate": "^1.7.7",
|
||||
"angular-aria": "^1.7.7",
|
||||
"angular-material": "^1.1.12",
|
||||
"angular-moment": "^1.3.0",
|
||||
"angular-translate": "^2.18.1",
|
||||
"angular-translate-loader-partial": "^2.18.1",
|
||||
|
@ -24,7 +23,7 @@
|
|||
"material-design-lite": "^1.3.0",
|
||||
"mg-crud": "^1.1.2",
|
||||
"moment-timezone": "^0.5.25",
|
||||
"npm": "^6.9.0",
|
||||
"npm": "^6.11.3",
|
||||
"oclazyload": "^0.6.3",
|
||||
"require-yaml": "0.0.1",
|
||||
"validator": "^6.3.0"
|
||||
|
|
|
@ -236,7 +236,6 @@ class Controller {
|
|||
|
||||
addTime(response) {
|
||||
if (response === 'ACCEPT') {
|
||||
console.log('newTime', this.newTime);
|
||||
let data = {workerFk: this.worker.id, timed: this.newTime};
|
||||
let query = `/api/WorkerTimeControls/addTime`;
|
||||
this.$http.post(query, data).then(() => {
|
||||
|
|
Loading…
Reference in New Issue