Commit 254e6ae0 authored by Evren Kutar's avatar Evren Kutar

datepicker for all date fields with jquery ui

parent a2e27992
......@@ -36,7 +36,6 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
debugger;
if (form.$valid) {
debugger;
Generator.submit($scope)
.success(function(data){
$location.path("/crud");
......
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
'use strict';
// TODO: clean console log items
angular.module('ulakbus.pinfo', ['ngRoute'])
.controller('PCtrl', function ($scope) {
$scope.testData = "<h1>This is main Dashboard</h1>";
});
\ No newline at end of file
......@@ -17,6 +17,7 @@
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="app.css">
<link href="styles/roboto/roboto.css" rel="stylesheet">
<link href="styles/jquery-ui.min.css" rel="stylesheet">
<link rel="stylesheet" href="bower_components/metisMenu/dist/metisMenu.min.css">
<link rel="stylesheet" href="bower_components/angular-loading-bar/build/loading-bar.min.css">
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css" type="text/css">
......@@ -89,6 +90,7 @@
<script src="app.js"></script>
<script src="app_routes.js"></script>
<script src="shared/scripts/theme.js"></script>
<script src="shared/scripts/jquery-ui.min.js"></script>
<script src="shared/directives.js"></script>
<script src="zetalib/interceptors.js"></script>
<script src="zetalib/general.js"></script>
......@@ -103,7 +105,6 @@
<script src="components/staff/staff_controller.js"></script>
<script src="components/student/student_controller.js"></script>
<script src="components/version/version.js"></script>
<!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>-->
</body>
</html>
This diff is collapsed.
......@@ -9,42 +9,22 @@
step="any"
sf-changed="form"
placeholder="{{form.placeholder}}"
class="form-control {{form.fieldHtmlClass}}"
class="form-control {{form.fieldHtmlClass}} datepickerfield"
id="{{form.key.slice(-1)[0]}}"
ng-model-options="form.ngModelOptions"
ng-model="dt"
ng-disabled="form.readonly"
schema-validate="form"
name="{{form.key.slice(-1)[0]}}"
aria-describedby="{{form.key.slice(-1)[0] + 'Status'}}"
aria-describedby="{{form.key.slice(-1)[0] + 'Status'}}"/>
type="date"
datepicker-popup
is-open="status.opened"
date-disabled="disabled(date, mode)"
close-text="Close"/>
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open($event)">
<button type="button" class="btn btn-default">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
</p>
<!--<input ng-if="!form.fieldAddonLeft && !form.fieldAddonRight"-->
<!--ng-show="form.key"-->
<!--type="{{form.type}}"-->
<!--step="any"-->
<!--sf-changed="form"-->
<!--placeholder="{{form.placeholder}}"-->
<!--class="form-control {{form.fieldHtmlClass}}"-->
<!--id="{{form.key.slice(-1)[0]}}"-->
<!--ng-model-options="form.ngModelOptions"-->
<!--ng-model="$$value$$"-->
<!--ng-disabled="form.readonly"-->
<!--schema-validate="form"-->
<!--name="{{form.key.slice(-1)[0]}}"-->
<!--aria-describedby="{{form.key.slice(-1)[0] + 'Status'}}">-->
<div ng-if="form.fieldAddonLeft || form.fieldAddonRight"
ng-class="{'input-group': (form.fieldAddonLeft || form.fieldAddonRight)}">
<span ng-if="form.fieldAddonLeft"
......
<button type="button" class="btn btn-primary" ng-click="onSubmit(formgenerated)">Kaydet</button>
<button type="button" class="btn btn-warning">Düzenle</button>
<button type="button" class="btn btn-danger">İptal</button>
\ No newline at end of file
This diff is collapsed.
......@@ -13,6 +13,8 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
return RESTURL.url + url;
};
generator.generate = function (scope, forms) {
// if no form in response (in case of list and single item request) return scope
if (!forms) {
return scope;
}
......@@ -26,87 +28,21 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
angular.forEach(scope.schema.properties, function (k, v) {
// check if type is date and if type date found change it to string
// and give it 'format':'date' property
// todo: make datepicker work below
// and give it 'type':'template' property and load it with template
if (k.type == 'date') {
k.title= k.title;
scope.form[scope.form.indexOf(v)] = {
"type": "template",
"templateUrl": "shared/templates/datefield.html",
"title": k.title,
"key": k.name,
"key": k.name
};
//var parentScope = scope.$parent.$parent.$parent.$parent;
//scope.today = function() {
// scope.dt = new Date();
//};
//scope.today();
//
//scope.clear = function () {
// scope.dt = null;
//};
//
//// Disable weekend selection
//scope.disabled = function(date, mode) {
// return ( mode === 'day' && ( date.getDay() === 0 || date.getDay() === 6 ) );
//};
//
//scope.toggleMin = function() {
// scope.minDate = scope.minDate ? null : new Date();
//};
//scope.toggleMin();
//scope.maxDate = new Date(2020, 5, 22);
//
//scope.open = function($event) {
// debugger;
// scope.status.opened = true;
//};
//
//scope.dateOptions = {
// formatYear: 'yy',
// startingDay: 1,
// initDate: new Date('01-01-1900')
//};
//
//scope.format = 'dd.MM.yyyy';
//
//scope.status = {
// opened: false
//};
//
//var tomorrow = new Date();
//tomorrow.setDate(tomorrow.getDate() + 1);
//var afterTomorrow = new Date();
//afterTomorrow.setDate(tomorrow.getDate() + 2);
//scope.events =
// [
// {
// date: tomorrow,
// status: 'full'
// },
// {
// date: afterTomorrow,
// status: 'partially'
// }
// ];
//
//scope.getDayClass = function(date, mode) {
// if (mode === 'day') {
// var dayToCheck = new Date(date).setHours(0,0,0,0);
//
// for (var i=0;i<$scope.events.length;i++){
// var currentDay = new Date($scope.events[i].date).setHours(0,0,0,0);
//
// if (dayToCheck === currentDay) {
// return $scope.events[i].status;
// }
// }
// }
//
// return '';
//};
scope.model[k.name] = generator.dateformatter(scope.model[k.name]);
// seek for datepicker field and initialize datepicker
scope.$watch(angular.element($('.datepickerfield')), function(){
$('.datepickerfield').datepicker();
});
}
if (k.type == 'int') {
......@@ -162,11 +98,6 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
scope.object_id = scope.form_params['object_id'];
//scope.triggerItem = function(id) {
// angular.element($(id));
// angular.element($(id)).triggerHandler('click');
//}
return generator.group(scope);
};
generator.group = function (formObject) {
......@@ -176,9 +107,9 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
//angular.forEach(formObject.objects, function(k, v) {
// check if date string and convert to date object
// todo: catch date object and convert
//debugger;
debugger;
//});
return formObject;
return Date(formObject);
};
generator.get_form = function (scope) {
return $http
......@@ -211,12 +142,6 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return re.test(email);
};
generator.generateButtons = function (scope) {
//scope.buttonplace = angular.element($('#myElement'));
scope.$watch("form", function(){
debugger;
});
};
generator.asyncValidators = {
emailNotValid: function (value) {
var deferred = $q.defer();
......
......@@ -18,6 +18,7 @@
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="app.css">
<link href="styles/roboto/roboto.css" rel="stylesheet">
<link href="styles/jquery-ui.min.css" rel="stylesheet">
<link rel="stylesheet" href="bower_components/metisMenu/dist/metisMenu.min.css">
<link rel="stylesheet" href="bower_components/angular-loading-bar/build/loading-bar.min.css">
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css" type="text/css">
......@@ -70,7 +71,6 @@
<!-- @if NODE_ENV == 'DEVELOPMENT' -->
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/angular-route/angular-route.min.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.min.js"></script>
<script src="bower_components/angular-resource/angular-resource.min.js"></script>
......@@ -83,17 +83,18 @@
<script src="bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"></script>
<script src="bower_components/angular-gettext/dist/angular-gettext.min.js"></script>
<!-- TODO: check all js and remove unused -->
<script src="bower_components/json3/lib/json3.min.js"></script>
<script src="bower_components/angular-loading-bar/build/loading-bar.min.js"></script>
<script src="bower_components/metisMenu/dist/metisMenu.min.js"></script>
<script src="bower_components/Chart.js/Chart.min.js"></script>
<script src="shared/translations.js"></script>
<script src="tmp/templates.js"></script>
<script src="app.js"></script>
<script src="app_routes.js"></script>
<script src="shared/scripts/theme.js"></script>
<script src="shared/scripts/jquery-ui.min.js"></script>
<script src="shared/directives.js"></script>
<script src="zetalib/interceptors.js"></script>
<script src="zetalib/general.js"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment