Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
2db36a56bb
|
@ -195,5 +195,24 @@ describe('Component vnAutocomplete', () => {
|
|||
|
||||
expect(controller.items).toEqual([{id: 3, name: 'The Joker', checked: false}, {id: 4, name: 'Joker', checked: false}]);
|
||||
});
|
||||
|
||||
it(`should call getItems function if there's no search value`, () => {
|
||||
let controller = $componentController('vnAutocomplete', {$scope, $element, $httpBackend, $timeout}, {url: 'test.com'});
|
||||
spyOn(controller, 'getItems');
|
||||
controller.findItems();
|
||||
|
||||
expect(controller.getItems).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
describe('getItem()', () => {
|
||||
it(`should perfom a query to fill the items without filter`, () => {
|
||||
let controller = $componentController('vnAutocomplete', {$scope, $element, $httpBackend, $timeout}, {url: 'test.com'});
|
||||
$httpBackend.whenGET(`test.com?filter={"skip":0,"limit":10,"order":"name ASC"}`).respond([{id: 1, name: 'Batman'}, {id: 2, name: 'Bruce Wayne'}]);
|
||||
$httpBackend.expectGET(`test.com?filter={"skip":0,"limit":10,"order":"name ASC"}`);
|
||||
controller.getItems();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.items).toEqual([{id: 1, name: 'Batman'}, {id: 2, name: 'Bruce Wayne'}]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,8 +38,6 @@ export {NAME as SUBMIT, directive as SubmitDirective} from './submit/submit';
|
|||
export {NAME as SUBMIT_MDL, factory as submitMdl} from './submit/submit.mdl';
|
||||
export {NAME as COMBO, directive as ComboDirective} from './combo/combo';
|
||||
export {NAME as COMBO_MDL, factory as comboMdl} from './combo/combo.mdl';
|
||||
/* export {NAME as DATE_PICKER, directive as DatePickerDirective} from './date-picker/date-picker';
|
||||
export {NAME as DATE_PICKER_MDL, factory as datePickerMdl} from './date-picker/date-picker.mdl';*/
|
||||
export {NAME as CARD, directive as CardDirective} from './card/card';
|
||||
export {NAME as CARD_MDL, factory as cardMdl} from './card/card.mdl';
|
||||
export {NAME as SWITCH, directive as SwitchDirective} from './switch/switch';
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
import {module as _module} from '../module';
|
||||
import * as resolveFactory from '../lib/resolveDefaultComponents';
|
||||
import * as normalizerFactory from '../lib/inputAttrsNormalizer';
|
||||
import * as util from '../lib/util';
|
||||
import Flatpickr from 'vendor/src/flatpickr';
|
||||
|
||||
const _NAME = 'datePicker';
|
||||
export const NAME = util.getName(_NAME);
|
||||
|
||||
directive.$inject = [resolveFactory.NAME, normalizerFactory.NAME, '$translate'];
|
||||
export function directive(resolve, normalizer, $translate) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: function(_, attrs) {
|
||||
normalizer.normalize(attrs);
|
||||
return resolve.getTemplate(_NAME, attrs);
|
||||
},
|
||||
link: function(scope, element, attrs) {
|
||||
let input = element[0];
|
||||
let flatpickrInstance;
|
||||
let initOptions = {};
|
||||
|
||||
if (attrs.iniOpts)
|
||||
initOptions = scope.$eval(attrs.iniOpts);
|
||||
|
||||
if (!initOptions.locale)
|
||||
initOptions.locale = $translate.use();
|
||||
|
||||
/*if (!initOptions.dateFormat && initOptions.locale === 'es')
|
||||
initOptions.dateFormat = 'd-m-Y';*/
|
||||
|
||||
if (!input.matches('input'))
|
||||
input = input.querySelector('input');
|
||||
|
||||
if (input)
|
||||
flatpickrInstance = new Flatpickr(input, initOptions);
|
||||
|
||||
scope.$watch(attrs.model, () => {
|
||||
let mdlField = element[0].firstChild.MaterialCheckbox;
|
||||
if (mdlField)
|
||||
mdlField.updateClasses_();
|
||||
});
|
||||
componentHandler.upgradeElement(element[0].firstChild);
|
||||
|
||||
element.on('$destroy', function() {
|
||||
flatpickrInstance.destroy();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
_module.directive(NAME, directive);
|
|
@ -1,4 +0,0 @@
|
|||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||
<input class="mdl-textfield__input *[className]*" type="text" name="*[name]*" ng-model="*[model]*" rule="*[rule]*" *[enabled]*/>
|
||||
<label class="mdl-textfield__label" translate>*[label]*</label>
|
||||
</div>
|
|
@ -1,14 +0,0 @@
|
|||
import {module} from '../module';
|
||||
import template from './date-picker.mdl.html';
|
||||
|
||||
export const NAME = 'vnDatePickerMdlFactory';
|
||||
export function factory() {
|
||||
return {
|
||||
template: template,
|
||||
default: {
|
||||
label: 'Label',
|
||||
enabled: 'enabled'
|
||||
}
|
||||
};
|
||||
}
|
||||
module.factory(NAME, factory);
|
Loading…
Reference in New Issue