Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bsdate warnings with latest ui-bootstrap #456

Merged
merged 1 commit into from
Apr 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/demos/bsdate/desc.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Date control is implemented via [Angular-ui bootstrap datepicker](http://angular-ui.github.io/bootstrap/#/datepicker).
You should include additional `ui-bootstrap-tpls.min.js`:

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.2.4/ui-bootstrap-tpls.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.3.1/ui-bootstrap-tpls.min.js"></script>

Add `ui.bootstrap` as module dependency:

Expand Down
2 changes: 1 addition & 1 deletion docs/demos/bstime/desc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Time control is implemented via [Angular-ui bootstrap timepicker](http://angular
**Currently it has only Bootstrap 2 version**, Bootstrap 3 version is [in progress](https://github.com/angular-ui/bootstrap/issues?milestone=6).
You should include additional `ui-bootstrap-tpls.min.js`:

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.2.4/ui-bootstrap-tpls.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.3.1/ui-bootstrap-tpls.min.js"></script>

Add `ui.bootstrap` as module dependency:

Expand Down
28 changes: 28 additions & 0 deletions docs/demos/dev-bsdate/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
app.controller('DevBsdateCtrl', function($scope) {
$scope.user = {
dob: new Date(1984, 4, 15),
startDate: '',
hireDate: new Date(2006, 4, 15)
};

$scope.getMinDate = function() {
return new Date(1984, 4, 01);
};

$scope.getMaxDate = function($event, elementOpened) {
return new Date(2016, 4, 01);
};

$scope.getInitDate = function($event, elementOpened) {
return new Date();
};

$scope.opened = {};

$scope.open = function($event, elementOpened) {
$event.preventDefault();
$event.stopPropagation();

$scope.opened[elementOpened] = !$scope.opened[elementOpened];
};
});
1 change: 1 addition & 0 deletions docs/demos/dev-bsdate/desc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dev
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this file is empty?

Copy link
Contributor Author

@ckosloski ckosloski Apr 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did what all the other "dev-" files did, which is just put "dev" in it. This is a dev only test and only shows up on the dev.html file.

116 changes: 116 additions & 0 deletions docs/demos/dev-bsdate/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
describe('bsdate', function() {

beforeEach(function() {
browser().navigateTo(mainUrl);
});

it('should show editor and submit new value', function() {
var s = '[ng-controller="DevBsdateCtrl"] ';

expect(element(s+'a#minMax').css('display')).not().toBe('none');
expect(element(s+'a#minMax').text()).toMatch('15/05/1984');
element(s+'a#minMax').click();
element(s+'form .input-group-btn button[type="button"]').click();

expect(element(s+'a#minMax').css('display')).toBe('none');
expect(element(s+'form[editable-form="$form"]').count()).toBe(1);
expect(element(s+'form input[type="text"]:visible').count()).toBe(1);
expect(element(s+'form input[type="text"]').val()).toBe('15-May-1984');
expect(element(s+'form .editable-buttons button[type="submit"]:visible').count()).toBe(1);
expect(element(s+'form .editable-buttons button[type="button"]:visible').count()).toBe(1);
expect(element(s+'ul.dropdown-menu:visible').count()).toBe(1);
expect(element(s+'form table button.btn-info span').text()).toMatch('15');

//set 01 May
element(s+'form table > tbody > tr:eq(0) > td:eq(3) > button').click();
expect(element(s+'ul.dropdown-menu:visible').count()).toBe(0);
expect(element(s+'form input[type="text"]').val()).toBe('01-May-1984');

//submit
element(s+'form button[type="submit"]').click();

expect(element(s+'a#minMax').css('display')).not().toBe('none');
expect(element(s+'a#minMax').text()).toMatch('01/05/1984');
expect(element(s+'form').count()).toBe(0);
});

it('should show editor and not submit new value when new value is outside of date range', function() {
var s = '[ng-controller="DevBsdateCtrl"] ';

expect(element(s+'a#minMax').css('display')).not().toBe('none');
expect(element(s+'a#minMax').text()).toMatch('15/05/1984');
element(s+'a#minMax').click();
element(s+'form .input-group-btn button[type="button"]').click();

expect(element(s+'a#minMax').css('display')).toBe('none');
expect(element(s+'form[editable-form="$form"]').count()).toBe(1);
expect(element(s+'form input[type="text"]:visible').count()).toBe(1);
expect(element(s+'form input[type="text"]').val()).toBe('15-May-1984');
expect(element(s+'form .editable-buttons button[type="submit"]:visible').count()).toBe(1);
expect(element(s+'form .editable-buttons button[type="button"]:visible').count()).toBe(1);
expect(element(s+'ul.dropdown-menu:visible').count()).toBe(1);
expect(element(s+'form table button.btn-info span').text()).toMatch('15');

//set 29 april
element(s+'form table > tbody > tr:eq(0) > td:eq(1) > button').click();
expect(element(s+'form table > tbody > tr:eq(0) > td:eq(1) > button').attr('disabled')).toBe("disabled");
expect(element(s+'ul.dropdown-menu:visible').count()).toBe(1);
expect(element(s+'form input[type="text"]').val()).toBe('15-May-1984');

//submit
element(s+'form button[type="submit"]').click();

expect(element(s+'a#minMax').css('display')).not().toBe('none');
expect(element(s+'a#minMax').text()).toMatch('');
expect(element(s+'form').count()).toBe(0);
});

it('should show editor with selected date set to the current date', function() {
var s = '[ng-controller="DevBsdateCtrl"] ';

expect(element(s+'a#initDate').css('display')).not().toBe('none');
expect(element(s+'a#initDate').text()).toMatch('empty');
element(s+'a#initDate').click();
element(s+'form .input-group-btn button[type="button"]').click();

expect(element(s+'a#initDate').css('display')).toBe('none');
expect(element(s+'form[editable-form="$form"]').count()).toBe(1);
expect(element(s+'form input[type="text"]:visible').count()).toBe(1);
expect(element(s+'form .editable-buttons button[type="submit"]:visible').count()).toBe(1);
expect(element(s+'form .editable-buttons button[type="button"]:visible').count()).toBe(1);
expect(element(s+'ul.dropdown-menu:visible').count()).toBe(1);
expect(element(s+'form table button.btn-sm span').text()).toMatch(new Date().getDate());
});


it('should show editor and submit new value and input field is read only', function() {
var s = '[ng-controller="DevBsdateCtrl"] ';

expect(element(s+'a#readOnly').css('display')).not().toBe('none');
expect(element(s+'a#readOnly').text()).toMatch('15/05/2006');
element(s+'a#readOnly').click();
element(s+'form .input-group-btn button[type="button"]').click();

expect(element(s+'a#readOnly').css('display')).toBe('none');
expect(element(s+'form[editable-form="$form"]').count()).toBe(1);
expect(element(s+'form input[type="text"]:visible').count()).toBe(1);
expect(element(s+'form input[type="text"]').attr('readonly')).toBe("readonly");
expect(element(s+'form input[type="text"]').val()).toBe('15-May-2006');
expect(element(s+'form .editable-buttons button[type="submit"]:visible').count()).toBe(1);
expect(element(s+'form .editable-buttons button[type="button"]:visible').count()).toBe(1);
expect(element(s+'ul.dropdown-menu:visible').count()).toBe(1);
expect(element(s+'form table button.btn-info span').text()).toMatch('15');

//set 01 May
element(s+'form table > tbody > tr:eq(0) > td:eq(3) > button').click();
expect(element(s+'ul.dropdown-menu:visible').count()).toBe(0);
expect(element(s+'form input[type="text"]').val()).toBe('02-May-2006');

//submit
element(s+'form button[type="submit"]').click();

expect(element(s+'a#readOnly').css('display')).not().toBe('none');
expect(element(s+'a#readOnly').text()).toMatch('02/05/2006');
expect(element(s+'form').count()).toBe(0);
});
});
35 changes: 35 additions & 0 deletions docs/demos/dev-bsdate/view.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div ng-controller="DevBsdateCtrl">
<a href="#" editable-bsdate="user.dob"
e-is-open="opened.$data"
e-ng-click="open($event,'$data')"
e-datepicker-popup="dd-MMMM-yyyy"
e-min-date="getMinDate()"
e-max-date="getMaxDate()"
e-on-open-focus="true"
id="minMax"
class="minMax">
{{ (user.dob | date:"dd/MM/yyyy") || 'empty' }}
</a>

<a href="#" editable-bsdate="user.startDate"
e-is-open="opened.$data"
e-ng-click="open($event,'$data')"
e-datepicker-popup="dd-MMMM-yyyy"
e-init-date="getInitDate()"
id="initDate"
class="initDate">
{{ (user.startDate | date:"dd/MM/yyyy") || 'empty' }}
</a>

<a href="#" editable-bsdate="user.hireDate"
e-is-open="opened.$data"
e-ng-click="open($event,'$data')"
e-datepicker-popup="dd-MMMM-yyyy"
e-init-date="getInitDate()"
e-on-open-focus="true"
e-readonly="true"
id="readOnly"
class="readOnly">
{{ (user.hireDate | date:"dd/MM/yyyy") || 'empty' }}
</a>
</div>
2 changes: 1 addition & 1 deletion docs/demos/typeahead/desc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Typeahead control is implemented via [Angular-ui bootstrap typeahead](http://ang
Basically it is normal `editable-text` control with additional `e-typeahead` attributes.
You should include additional `ui-bootstrap-tpls.min.js`:

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.2.4/ui-bootstrap-tpls.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.3.1/ui-bootstrap-tpls.min.js"></script>

Then add `ui.bootstrap` as module dependency:

Expand Down
2 changes: 1 addition & 1 deletion docs/jade/scripts-dev.jade
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ script(src='libs/angular/1.5.0/angular-mocks.js')
script(src="libs/bootstrap/3.3.6/js/bootstrap.js")

//angular-ui-bootstrap
script(src="libs/angular-ui/bootstrap/ui-bootstrap-tpls-1.2.4.min.js")
script(src="libs/angular-ui/bootstrap/ui-bootstrap-tpls-1.3.1.min.js")

//ui-select
script(src="libs/ui-select/0.16.0/select.js")
Expand Down
4 changes: 2 additions & 2 deletions docs/jade/scripts-prod.jade
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ script(src="libs/jquery/jquery-1.10.2.min.js")
script(src="libs/bootstrap/3.3.6/js/bootstrap.js")

//angular-ui-bootstrap
script(src="libs/angular-ui/bootstrap/ui-bootstrap-tpls-1.2.4.min.js")
script(src="libs/angular-ui/bootstrap/ui-bootstrap-tpls-1.3.1.min.js")

//ui-select
script(src="libs/ui-select/0.16.0/select.js")

//moment
script(src="libs/moment.min.2.5.0.js")
script(src="libs/moment.min.2.12.0.js")

//google-code-prettify
script(src='libs/google-code-prettify/run_prettify.js')
Expand Down
3 changes: 2 additions & 1 deletion docs/js/structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = [
{id: 'dev-text', text: 'Dev Tests', type: 'demos', env: 'dev', items: [
{id: 'dev-text'},
{id: 'dev-form'},
{id: 'dev-select'}
{id: 'dev-select'},
{id: 'dev-bsdate'}
]}
];
10 changes: 10 additions & 0 deletions libs/angular-ui/bootstrap/ui-bootstrap-tpls-1.3.1.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions libs/moment.min.2.12.0.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/js/directives/bsdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ angular.module('xeditable').directive('editableBsdate', ['editableDirectiveFacto
inputDatePicker.attr('is-open', this.attrs.eIsOpen);
inputDatePicker.attr('date-disabled', this.attrs.eDateDisabled);
inputDatePicker.attr('uib-datepicker-popup', this.attrs.eDatepickerPopup);
inputDatePicker.attr('min-date', this.attrs.eMinDate);
inputDatePicker.attr('max-date', this.attrs.eMaxDate);
inputDatePicker.attr('year-range', this.attrs.eYearRange || 20);
inputDatePicker.attr('show-button-bar', this.attrs.eShowButtonBar || true);
inputDatePicker.attr('current-text', this.attrs.eCurrentText || 'Today');
Expand All @@ -33,6 +31,8 @@ angular.module('xeditable').directive('editableBsdate', ['editableDirectiveFacto
inputDatePicker.attr('datepicker-append-to-body', this.attrs.eDatePickerAppendToBody || false);
inputDatePicker.attr('date-disabled', this.attrs.eDateDisabled);
inputDatePicker.attr('name', this.attrs.eName);
inputDatePicker.attr('on-open-focus', this.attrs.eOnOpenFocus || true);
inputDatePicker.attr('ng-readonly', this.attrs.eReadonly || false);

this.scope.dateOptions = {
formatDay: this.attrs.eFormatDay || 'dd',
Expand All @@ -45,8 +45,10 @@ angular.module('xeditable').directive('editableBsdate', ['editableDirectiveFacto
startingDay: this.attrs.eStartingDay || 0,
minMode: this.attrs.eMinMode || 'day',
maxMode: this.attrs.eMaxMode || 'year',
initDate: this.attrs.eInitDate || new Date(),
datepickerMode: this.attrs.eDatepickerMode || 'day'
initDate: this.scope.$eval(this.attrs.eInitDate) || new Date(),
datepickerMode: this.attrs.eDatepickerMode || 'day',
maxDate: this.scope.$eval(this.attrs.eMaxDate) || null,
minDate: this.scope.$eval(this.attrs.eMinDate) || null
};

inputDatePicker.attr('datepicker-options', "dateOptions");
Expand Down
1 change: 1 addition & 0 deletions test/e2e/dev-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<script src="../../docs/demos/dev-text/test.js"></script>
<script src="../../docs/demos/dev-form/test.js"></script>
<script src="../../docs/demos/dev-select/test.js"></script>
<script src="../../docs/demos/dev-bsdate/test.js"></script>
</head>
<body>
</body>
Expand Down