Skip to content

Commit 11f732e

Browse files
committed
feat(4665): init new date picker
1 parent 9f5be3f commit 11f732e

File tree

6 files changed

+655
-327
lines changed

6 files changed

+655
-327
lines changed

.prettierrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": false,
4+
"htmlWhitespaceSensitivity": "ignore",
5+
"insertPragma": false,
6+
"jsxBracketSameLine": true,
7+
"jsxSingleQuote": true,
8+
"printWidth": 300,
9+
"proseWrap": "preserve",
10+
"quoteProps": "preserve",
11+
"requirePragma": false,
12+
"semi": true,
13+
"singleQuote": true,
14+
"tabWidth": 2,
15+
"trailingComma": "es5",
16+
"useTabs": true,
17+
"vueIndentScriptAndStyle": false,
18+
"endOfLine": "auto",
19+
"overrides": [
20+
{
21+
"files": "*.html",
22+
"options": {
23+
"parser": "angular"
24+
}
25+
}
26+
]
27+
}

bower.json

Lines changed: 59 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,61 @@
11
{
2-
"name": "lets-angular-framework-core",
3-
"version": "0.0.9",
4-
"description": "Core Module for Lets Angular Framework Dependencies",
5-
"authors": [
6-
"Lets Comunica"
7-
],
8-
"dependencies": {
9-
"angular": "1.4.1",
10-
"angular-animate": "1.4.0",
11-
"angular-cookies": "1.3.4",
12-
"angular-touch": "1.3.4",
13-
"angular-sanitize": "1.3.4",
14-
"ngstorage": "0.3.7",
15-
"jquery": "2.1.3",
16-
"angular-ui-router": "0.2.13",
17-
"bootstrap-sass": "3.3.4",
18-
"angular-bootstrap": "~0.13.3",
19-
"font-awesome": "~4.7.0",
20-
"open-sans-fontface": "1.4.0",
21-
"animate.css": "3.3.0",
22-
"slimScroll": "1.3.6",
23-
"widgster": "0.0.2",
24-
"jquery-touchswipe": "1.6.9",
25-
"angular-ui-event": "1.0.0",
26-
"backgrid": "0.3.5",
27-
"backgrid-paginator": "03632df8ad238e3d043c0fd471a6c78494e1bdfc",
28-
"datatables": "~1.10.7",
29-
"angular-resource": "~1.4.3",
30-
"underscore": "~1.8.3",
31-
"backbone": "~1.2.1",
32-
"backbone.paginator": "~2.0.2",
33-
"parsleyjs": "~2.1.3",
34-
"restangular": "^1.5.2",
35-
"angular-viacep": "^0.1.0",
36-
"ng-cpf-cnpj": "^0.0.5",
37-
"angular-ui-utils": "bower-jq",
38-
"angular-ui-mask": "^1.8.3",
39-
"moment": "^2.13.0",
40-
"backgrid-moment-cell": "^0.3.8",
41-
"satellizer": "^0.14.0",
42-
"backgrid-filter": "^0.3.7",
43-
"jquery-mask-plugin": "igorescobar/jQuery-Mask-Plugin#^1.14.0",
44-
"angular-i18n": "^1.5.6",
45-
"ngToast": "ngtoast#^2.0.0",
46-
"PACE": "pace-ng-file-upload-patch#^1.0.3",
47-
"ng-file-upload": "^12.0.4",
48-
"angular-timer": "^1.3.5",
49-
"angular-moment-filter": "*",
50-
"checklist-model": "^0.11.0",
51-
"moment-duration-format": "^2.2.1",
52-
"angular-bootstrap-toggle": "^0.1.3",
53-
"ng-dropzone": "https://github.com/thatisuday/ng-dropzone.git#v2.0.2",
54-
"swangular": "^1.4.3",
55-
"angularjs-dropdown-multiselect": "^1.11.8"
56-
},
57-
"devDependencies": {},
58-
"main": [
59-
"./dist/lets.min.js",
60-
"./dist/lets.min.css"
61-
],
62-
"ignore": [],
63-
"keywords": [
64-
"angular",
65-
"directive",
66-
"module"
67-
],
68-
"license": "MIT"
2+
"name": "lets-angular-framework-core",
3+
"version": "0.0.9",
4+
"description": "Core Module for Lets Angular Framework Dependencies",
5+
"authors": ["Lets Comunica"],
6+
"dependencies": {
7+
"angular": "1.4.1",
8+
"angular-animate": "1.4.0",
9+
"angular-cookies": "1.3.4",
10+
"angular-touch": "1.3.4",
11+
"angular-sanitize": "1.3.4",
12+
"ngstorage": "0.3.7",
13+
"jquery": "2.1.3",
14+
"angular-ui-router": "0.2.13",
15+
"bootstrap-sass": "3.3.4",
16+
"angular-bootstrap": "~0.13.3",
17+
"font-awesome": "~4.7.0",
18+
"open-sans-fontface": "1.4.0",
19+
"animate.css": "3.3.0",
20+
"slimScroll": "1.3.6",
21+
"widgster": "0.0.2",
22+
"jquery-touchswipe": "1.6.9",
23+
"angular-ui-event": "1.0.0",
24+
"backgrid": "0.3.5",
25+
"backgrid-paginator": "03632df8ad238e3d043c0fd471a6c78494e1bdfc",
26+
"datatables": "~1.10.7",
27+
"angular-resource": "~1.4.3",
28+
"underscore": "~1.8.3",
29+
"backbone": "~1.2.1",
30+
"backbone.paginator": "~2.0.2",
31+
"parsleyjs": "~2.1.3",
32+
"restangular": "^1.5.2",
33+
"angular-viacep": "^0.1.0",
34+
"ng-cpf-cnpj": "^0.0.5",
35+
"angular-ui-utils": "bower-jq",
36+
"angular-ui-mask": "^1.8.3",
37+
"moment": "^2.13.0",
38+
"backgrid-moment-cell": "^0.3.8",
39+
"satellizer": "^0.14.0",
40+
"backgrid-filter": "^0.3.7",
41+
"jquery-mask-plugin": "igorescobar/jQuery-Mask-Plugin#^1.14.0",
42+
"angular-i18n": "^1.5.6",
43+
"ngToast": "ngtoast#^2.0.0",
44+
"PACE": "pace-ng-file-upload-patch#^1.0.3",
45+
"ng-file-upload": "^12.0.4",
46+
"angular-timer": "^1.3.5",
47+
"angular-moment-filter": "*",
48+
"checklist-model": "^0.11.0",
49+
"moment-duration-format": "^2.2.1",
50+
"angular-bootstrap-toggle": "^0.1.3",
51+
"ng-dropzone": "https://github.com/thatisuday/ng-dropzone.git#v2.0.2",
52+
"swangular": "^1.4.3",
53+
"angularjs-dropdown-multiselect": "^1.11.8",
54+
"angular-daterangepicker": "^0.3.0"
55+
},
56+
"devDependencies": {},
57+
"main": ["./dist/lets.min.js", "./dist/lets.min.css"],
58+
"ignore": [],
59+
"keywords": ["angular", "directive", "module"],
60+
"license": "MIT"
6961
}

package.json

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"test": "gulp test"
1010
},
1111
"devDependencies": {
12+
"del": "~2.0.2",
1213
"gulp": "^3.9.1",
1314
"gulp-angular-filesort": "~1.1.1",
1415
"gulp-angular-templatecache": "~1.8.0",
@@ -27,16 +28,50 @@
2728
"gulp-replace": "~0.5.4",
2829
"gulp-rev": "~6.0.1",
2930
"gulp-rev-replace": "~0.4.2",
30-
"gulp-sass": "~2.0.4",
31+
"gulp-sass": "^3.0.0",
3132
"gulp-size": "~2.0.0",
3233
"gulp-sourcemaps": "~1.6.0",
3334
"gulp-uglify": "~1.4.1",
3435
"gulp-useref": "~1.3.0",
3536
"gulp-util": "^3.0.8",
36-
"wrench": "~1.5.8",
37-
"del": "~2.0.2"
37+
"wrench": "~1.5.8"
3838
},
3939
"engines": {
4040
"node": ">=0.10.0"
41+
},
42+
"eslintConfig": {
43+
"extends": [
44+
"plugin:angular/johnpapa"
45+
],
46+
"plugins": [
47+
"angular"
48+
],
49+
"rules": {
50+
"angular/no-service-method": 0,
51+
"angular/file-name": 0,
52+
"angular/controller-as-vm": 0,
53+
"angular/document-service": 0,
54+
"angular/controller-name": 0,
55+
"angular/controller-as": 0,
56+
"angular/timeout-service": 0,
57+
"angular/window-service": 0
58+
},
59+
"env": {
60+
"es6": true,
61+
"browser": true,
62+
"jasmine": true
63+
},
64+
"ecmaFeatures": {
65+
"modules": true
66+
},
67+
"globals": {
68+
"angular": true,
69+
"module": true,
70+
"inject": true,
71+
"jQuery": true,
72+
"$": true,
73+
"swal": true,
74+
"ngDescribe": true
75+
}
4176
}
4277
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
(function () {
2+
'use strict';
3+
4+
angular.module('letsAngular').directive('newDatePicker', newDatePicker);
5+
6+
newDatePicker.$inject = ['$compile', 'jQuery'];
7+
8+
function newDatePicker($compile, jQuery) {
9+
var controllerName = 'vm';
10+
return {
11+
restrict: 'A',
12+
require: '?ngModel',
13+
scope: true,
14+
terminal: true,
15+
priority: 1,
16+
compile: function (element, attrs) {
17+
var wrapper = angular.element(`
18+
<div class="input-group">
19+
<span class="input-group-btn">
20+
21+
<button type="button" class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></button>
22+
</span>
23+
</div>`);
24+
25+
function setAttributeIfNotExists(name, value) {
26+
var oldValue = element.attr(name);
27+
if (!angular.isDefined(oldValue) || oldValue === false) {
28+
element.attr(name, value);
29+
}
30+
}
31+
// console.log({controllerName: controllerName});
32+
33+
controllerName = Object.assign(controllerName, options);
34+
console.log({obj_: controllerName});
35+
// setAttributeIfNotExists('type', 'text');
36+
// setAttributeIfNotExists('is-open', controllerName + '.popupOpen');
37+
// setAttributeIfNotExists('show-button-bar', false);
38+
// setAttributeIfNotExists('show-weeks', false);
39+
// setAttributeIfNotExists('datepicker-options', 'datepickerOptions');
40+
41+
element.addClass('form-control');
42+
element.removeAttr('new-date-picker');
43+
element.after(wrapper);
44+
wrapper.prepend(element);
45+
46+
return function (scope, element) {
47+
// var options = {
48+
// locale: {
49+
// format: 'DD/MM/YYYY',
50+
// minYear: 1901,
51+
// maxYear: parseInt(moment().format('YYYY'), 10),
52+
// applyLabel: 'Aplicar',
53+
// cancelLabel: 'Cancelar',
54+
// daysOfWeek: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
55+
// monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
56+
// },
57+
// singleDatePicker: true,
58+
// showDropdowns: false,
59+
// timePicker: false,
60+
// firstDay: 1,
61+
// };
62+
63+
if (scope.data === undefined) scope.data = {};
64+
65+
// if (!scope.field) {
66+
// scope.field = {customOptions: []};
67+
// if (attrs.fwDatePickerNgModelParent) {
68+
// options.initDate = new Date(scope.$parent[attrs.ngModel]);
69+
// scope.$parent[attrs.ngModel] = angular.copy(options.initDate);
70+
// } else {
71+
// options.initDate = new Date(scope[attrs.ngModel]);
72+
// scope[attrs.ngModel] = angular.copy(options.initDate);
73+
// }
74+
// } else if (scope.data[scope.field.name] != null) {
75+
// options.initDate = new Date(scope.data[scope.field.name]);
76+
// scope.data[scope.field.name] = angular.copy(options.initDate);
77+
// }
78+
79+
// var format = 'dd/MM/yyyy';
80+
81+
// if (scope.field.customOptions.monthpicker !== undefined) {
82+
// options.datepickerMode = "'month'";
83+
// options.minMode = 'month';
84+
85+
// format = 'MM/yyyy';
86+
// }
87+
88+
// element.find('input').attr('datepicker-popup', format);
89+
90+
// element.find('input').blur(function () {
91+
// if (!moment(this.value, format).isValid() && this.value !== '') {
92+
// scope.field.error = true;
93+
// } else {
94+
// scope.field.error = false;
95+
// }
96+
// });
97+
98+
// element.find('input').focus(function (e) {
99+
// scope.vm.openPopup(e);
100+
// });
101+
102+
scope.dateRangePicker = {
103+
date: {startDate: moment().subtract(1, 'years'), endDate: moment().add(1, 'years')},
104+
picker: null,
105+
singleDatePicker: true,
106+
options: {
107+
pickerClasses: 'custom-display',
108+
buttonClasses: 'btn',
109+
applyButtonClasses: 'btn-primary',
110+
cancelButtonClasses: 'btn-danger',
111+
locale: {
112+
applyLabel: 'Aplicar',
113+
cancelLabel: 'Cancelar',
114+
daysOfWeek: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
115+
monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
116+
customRangeLabel: 'Custom range',
117+
separator: '/',
118+
format: 'DD/MM/YYYY',
119+
minYear: 1901,
120+
maxYear: parseInt(moment().format('YYYY'), 10), //will give you 2017-01-06
121+
},
122+
// ranges: {
123+
// 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
124+
// 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
125+
// },
126+
eventHandlers: {
127+
'apply.daterangepicker': function (event, picker) {
128+
console.log('applied');
129+
},
130+
},
131+
},
132+
};
133+
$compile(element)(scope);
134+
};
135+
},
136+
controller: function ($scope) {
137+
// this.popupOpen = false;
138+
// this.openPopup = function ($event) {
139+
// $event.preventDefault();
140+
// $event.stopPropagation();
141+
// this.popupOpen = true;
142+
// };
143+
},
144+
controllerAs: controllerName,
145+
};
146+
}
147+
})();

src/lets.module.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
'ckeditor',
2020
'thatisuday.dropzone',
2121
'swangular',
22-
'angularjs-dropdown-multiselect'
22+
'angularjs-dropdown-multiselect',
23+
'daterangepicker'
2324
]);
2425

2526
// ----------------------------
@@ -88,4 +89,4 @@
8889
function appConfig($stateProvider, $httpProvider) {
8990

9091
};
91-
})();
92+
})();

0 commit comments

Comments
 (0)