Commit 2aa8040c authored by Evren Kutar's avatar Evren Kutar

linked model typeahead fix

uibootstrap upgrade to 0.14.3
parent 29ec6a0b
......@@ -121,7 +121,7 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
*
* @returns {object}
*/
.controller('CRUDListFormCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams, CrudUtility) {
.controller('CRUDListFormCtrl', function ($scope, $rootScope, $location, $http, $log, $uibModal, $timeout, Generator, $routeParams, CrudUtility) {
// reloadData must be a json object
$scope.reload = function (reloadData) {
$scope.form_params.cmd = $scope.reload_cmd;
......
......@@ -4,5 +4,5 @@
<crud-form-directive ng-if="forms"></crud-form-directive>
<crud-list-directive ng-if="objects"></crud-list-directive>
</div>
<crud-filters ng-if="meta.allow_filters === true" class="col-md-4"></crud-filters>
<crud-filters ng-if="meta.allow_filters === true" class="col-md-4 filtre"></crud-filters>
</div>
\ No newline at end of file
<div class="starter-template container">
<sort-directive></sort-directive>
<sort-directive ng-if="meta['allow_sort']===true"></sort-directive>
<search-directive ng-if="meta['allow_search']===true"></search-directive>
<div class="clearfix"></div>
<!--<h1>{{form_params.model || form_params.wf}}</h1>-->
......
......@@ -37,9 +37,10 @@
</div>
<!-- /.sidebar-collapse -->
<footer ng-class="{hidden: $root.collapsed}">
<a class="btn btn-large btn-success" href="javascript:void(0);" onclick="javascript:introJs().setOptions({
'nextLabel': 'Sonraki', 'prevLabel': 'Öncek', 'skipLabel': 'Atla', 'doneLabel': 'Bitir' }).start();">Yardım
Rehberi</a><br>
<span>v <app-version></app-version> &copy; ZetaOps</span>
</footer>
</div>
......@@ -19,7 +19,7 @@
</span>
<input type="text"
ng-model="$$value$$"
typeahead="item.name for item in form.titleMap"
uib-typeahead="item as item.name for item in form.titleMap | filter:{name:$viewValue}"
typeahead-on-select="form.onSelect($item)"
placeholder="{{form.title}}"
ng-model-options="form.ngModelOptions"
......
<div class="modal-body">
<h3>{{schema.title}}</h3>
<form name="listnodeform" sf-schema="schema" sf-form="form" sf-model="model"></form>
<form name="modalForm" sf-schema="schema" sf-form="form" sf-model="model" modal-form-locator></form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" ng-click="onSubmit(listnodeform)">OK</button>
<button type="submit" class="btn btn-primary" ng-click="onNodeSubmit()">OK</button>
<button type="button" class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
\ No newline at end of file
......@@ -31,7 +31,8 @@ angular.module('formService', ['ui.bootstrap'])
*/
generator.makeUrl = function (scope) {
var getparams = scope.form_params.param ? "?" + scope.form_params.param + "=" + scope.form_params.id : "";
return RESTURL.url + scope.url + '/' + (scope.form_params.model || '') + getparams;
//return RESTURL.url + scope.url + '/' + (scope.form_params.model || '') + getparams;
return RESTURL.url + scope.url + getparams;
};
/**
* @name generate
......@@ -222,7 +223,36 @@ angular.module('formService', ['ui.bootstrap'])
if (v.type === 'model') {
var formitem = scope.form[scope.form.indexOf(k)];
var modelscope = {"url": v.wf, "form_params": {model: v.model_name, cmd: v.list_cmd}};
var modelScope = {"url": v.wf, "form_params": {model: v.model_name, cmd: v.list_cmd}};
scope.$on('refreshTitleMap', function (event, data) {
// todo: write a function to refresh titleMap after new item add to linkedModel
});
scope.generateTitleMap = function (modelScope) {
generator.get_list(modelScope).then(function (res) {
formitem.titleMap = [];
angular.forEach(res.data.objects, function (item) {
debugger;
if (item !== "-1") {
formitem.titleMap.push({
"value": item.key,
"name": item.value
});
}
// get selected item from titleMap using model value
if (item.key === scope.model[k]) {
formitem.selected_item = {value: item.key, name: item.value};
}
});
// after rendering change input value to model value
scope.$watch(document.querySelector('input[name=' + v.model_name + ']'),
function () {
angular.element(document.querySelector('input[name=' + v.model_name + ']')).val(formitem.selected_item.name);
}
);
})
};
formitem = {
type: "template",
......@@ -233,6 +263,37 @@ angular.module('formService', ['ui.bootstrap'])
name: v.model_name,
model_name: v.model_name,
selected_item: {},
titleMap: scope.generateTitleMap(modelScope),
onSelect: function (item) {
scope.model[k] = item.value;
},
onDropdownSelect: function (item, inputname) {
scope.model[k] = item.value;
jQuery('input[name=' + inputname + ']').val(item.name);
}
};
scope.form[scope.form.indexOf(k)] = formitem;
}
if (v.type === 'filter_interface') {
var formitem = scope.form[scope.form.indexOf(k)];
var modelscope = {"url": v.wf, "form_params": {model: v.model_name, cmd: v.list_cmd}};
scope.$on('refreshTitleMap', function (event, data) {
// todo: write a function to refresh titleMap after new item add to linkedModel
});
formitem = {
type: "template",
templateUrl: "shared/templates/multiselect.html",
title: v.title,
wf: v.wf,
add_cmd: v.add_cmd,
name: v.model_name,
model_name: v.model_name,
selected_item: {},
titleMap: generator.get_list(modelscope).then(function (res) {
formitem.titleMap = [];
angular.forEach(res.data.objects, function (item) {
......@@ -263,8 +324,6 @@ angular.module('formService', ['ui.bootstrap'])
}
};
// get model objects from db and add to select list
scope.form[scope.form.indexOf(k)] = formitem;
}
......@@ -562,11 +621,11 @@ angular.module('formService', ['ui.bootstrap'])
* @description
* controller for listnode, node and linkedmodel modal and save data of it
* @param items
* @requires $scope, $modalInstance, $route
* @requires $scope, $uibModalInstance, $route
* @returns returns value for modal
*/
.controller('ModalCtrl', function ($scope, $modalInstance, Generator, items) {
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) {
$scope[key] = items[key];
});
......@@ -590,13 +649,19 @@ angular.module('formService', ['ui.bootstrap'])
$scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate');
if (form.$valid) {
// send form to modalinstance result function
$modalInstance.close($scope);
$uibModalInstance.close($scope);
}
};
$scope.onNodeSubmit = function () {
$uibModalInstance.close($scope);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
$uibModalInstance.dismiss('cancel');
};
})
......@@ -604,15 +669,15 @@ angular.module('formService', ['ui.bootstrap'])
* @name modalForNodes
* @description
* add modal directive for nodes
* @param $modal
* @param $uibModal
* @returns openmodal directive
*/
.directive('modalForNodes', function ($modal) {
.directive('modalForNodes', function ($uibModal, Generator) {
return {
link: function (scope, element, attributes) {
element.on('click', function () {
var modalInstance = $modal.open({
var modalInstance = $uibModal.open({
animation: false,
templateUrl: 'shared/templates/listnodeModalContent.html',
controller: 'ModalCtrl',
......@@ -635,7 +700,20 @@ angular.module('formService', ['ui.bootstrap'])
// tell result.then function which item to edit
node.edit = attribs[3];
return node;
scope.node.schema.wf = scope.node.url;
angular.forEach(scope.node.schema.properties, function (value, key) {
scope.node.schema.properties[key].wf = scope.node.url;
scope.node.schema.properties[key].list_cmd = 'select_list';
});
var newscope = {
url: scope.node.url,
form_params: {model: scope.node.schema.model_name}
};
Generator.generate(newscope, {forms:scope.node});
return scope.node;
}
}
});
......@@ -666,15 +744,15 @@ angular.module('formService', ['ui.bootstrap'])
* @name addModalForLinkedModel
* @description
* add modal directive for linked models
* @param $modal, Generator
* @param $uibModal, Generator
* @returns openmodal directive
*/
.directive('addModalForLinkedModel', function ($modal, $rootScope, $route, Generator) {
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return {
link: function (scope, element) {
element.on('click', function () {
var modalInstance = $modal.open({
var modalInstance = $uibModal.open({
animation: true,
backdrop:'static',
templateUrl: 'shared/templates/linkedModelModalContent.html',
......@@ -722,17 +800,17 @@ angular.module('formService', ['ui.bootstrap'])
* @name editModalForLinkedModel
* @description
* edit modal directive for linked models
* @param $modal, Generator
* @param $uibModal, Generator
* @returns openmodal directive
*/
// todo: useless modal check if any use cases?? and delete if useless
.directive('editModalForLinkedModel', function ($modal, Generator) {
.directive('editModalForLinkedModel', function ($uibModal, Generator) {
return {
link: function (scope, element) {
element.on('click', function () {
var modalInstance = $modal.open({
var modalInstance = $uibModal.open({
animation: false,
templateUrl: 'shared/templates/linkedModelModalContent.html',
controller: 'ModalCtrl',
......
......@@ -14,7 +14,7 @@
"angular-route": "1.4.x",
"angular-resource": "1.4.x",
"angular-cookies": "1.4.x",
"angular-bootstrap": "0.13.1",
"angular-bootstrap": "0.14.3",
"font-awesome": "4.3.0",
"angular-schema-form": "0.8.3",
"angular-loading-bar": "~0.8.0",
......
This diff is collapsed.
This diff is collapsed.
......@@ -28,7 +28,7 @@ angular.module("components/crud/templates/crud.html", []).run(["$templateCache",
" <crud-form-directive ng-if=\"forms\"></crud-form-directive>\n" +
" <crud-list-directive ng-if=\"objects\"></crud-list-directive>\n" +
" </div>\n" +
" <crud-filters ng-if=\"meta.allow_filters === true\" class=\"col-md-4\"></crud-filters>\n" +
" <crud-filters ng-if=\"meta.allow_filters === true\" class=\"col-md-4 filtre\"></crud-filters>\n" +
"</div>");
}]);
......@@ -299,28 +299,10 @@ angular.module("components/dashboard/dashboard.html", []).run(["$templateCache",
$templateCache.put("components/dashboard/dashboard.html",
"<div ng-app=\"ulakbus.dashboard\" class=\"dashboard\">\n" +
" <div class=\"starter-template\">\n" +
"\n" +
" <!-- \n" +
" <div class=\"row\">\n" +
" <div class=\"major-buttons\">\n" +
" <div class=\"col-md-4\">\n" +
" <a href=\"\"><button type=\"button\" class=\"btn btn-personnel brand-bg\" ng-click=\"section(2)\"><i class=\"fa fa-user\"></i>\n" +
" PERSONEL İŞLERİ</button></a>\n" +
" </div>\n" +
" <div class=\"col-md-4\">\n" +
" <a href=\"\"><button type=\"button\" class=\"btn btn-student brand-bg\" ng-click=\"section(0)\"><i\n" +
" class=\"fa fa-graduation-cap\"></i> ÖĞRENCİ İŞLERİ</button></a>\n" +
" </div>\n" +
" <div class=\"col-md-4\">\n" +
" <a href=\"\"><button type=\"button\" class=\"btn btn-system brand-bg\" ng-click=\"section(3)\"><i class=\"fa fa-gears\"></i>\n" +
" SİSTEM</button></a>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" -->\n" +
" \n" +
" <div class=\"dashboard-main-search clearfix\">\n" +
" <div class=\"dashboard-student-search\" data-step=\"1\" data-intro=\"test intro\">\n" +
" <div class=\"dashboard-student-search\" data-step=\"2\"\n" +
" data-intro=\"isim veya tcno ile öğrenci araması yapabilirsiniz.\">\n" +
" <center>\n" +
" <h3>ÖĞRENCİ</h3>\n" +
" <input type=\"text\" placeholder=\"Öğrenci ara\" ng-model=\"student_kw\" ng-keyup=\"search('ogrenci')\">\n" +
......@@ -336,7 +318,8 @@ angular.module("components/dashboard/dashboard.html", []).run(["$templateCache",
" <!-- end of dashboard-student-search-results -->\n" +
" </div>\n" +
" <!-- end of dashboard-student-search -->\n" +
" <div class=\"dashboard-personnel-search\">\n" +
" <div class=\"dashboard-personnel-search\" data-step=\"3\"\n" +
" data-intro=\"isim veya tcno ile personel araması yapabilirsiniz.\">\n" +
" <center>\n" +
" <h3>PERSONEL</h3>\n" +
" <input type=\"text\" placeholder=\"Personel ara\" ng-model=\"staff_kw\" ng-keyup=\"search('personel')\">\n" +
......@@ -357,7 +340,8 @@ angular.module("components/dashboard/dashboard.html", []).run(["$templateCache",
" \n" +
" <div class=\"right-sidebar\">\n" +
"\n" +
" <div class=\"right-sidebar-box\">\n" +
" <div class=\"right-sidebar-box\" data-step=\"4\"\n" +
" data-intro=\"mesajlar, yapılan görevlerin son durumları, duyurular ve son yapılan işlemleri buradan takip edebilirsiniz.\">\n" +
" <div class=\"right-sidebar-messages\">\n" +
"\n" +
" <div class=\"right-sidebar-title clearfix\">\n" +
......@@ -392,21 +376,6 @@ angular.module("components/dashboard/dashboard.html", []).run(["$templateCache",
" <h3>Görevler</h3>\n" +
" <span><a href=\"javascript:void(0)\">Tüm Görevler</a></span>\n" +
" </div>\n" +
" <!-- end of right-sidebar-title -->\n" +
"\n" +
" <!--<div class=\"right-sidebar-task-block\">-->\n" +
" <!--<div class=\"task-type\">Devam Eden Görevler</div>-->\n" +
" <!--<a href=\"javascript:void(0)\">-->\n" +
" <!--<div class=\"task-title\">Öğrenci Kayıt</div>-->\n" +
" <!--<div class=\"progress\">-->\n" +
" <!--<div class=\"progress-bar\" role=\"progressbar\" aria-valuenow=\"25\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"min-width: 2em; width:25%;\">-->\n" +
" <!--25%-->\n" +
" <!--</div>-->\n" +
" <!--</div>-->\n" +
" <!--&lt;!&ndash; end of progress &ndash;&gt;-->\n" +
" <!--</a>-->\n" +
" <!--</div>-->\n" +
" <!-- end of right-sidebar-task-block -->\n" +
"\n" +
" <div class=\"right-sidebar-task-block\">\n" +
" <!--<div class=\"task-type\">Onay Bekleyen Görevler</div>-->\n" +
......@@ -451,13 +420,6 @@ angular.module("components/dashboard/dashboard.html", []).run(["$templateCache",
" <h3>Son İşlemler</h3>\n" +
" <span><a href=\"javascript:void(0)\">Tüm İşlemler</a></span>\n" +
" </div>\n" +
" <!-- end of right-sidebar-title -->\n" +
"\n" +
" <!--<div class=\"right-sidebar-last-action-block\">-->\n" +
" <!--<a href=\"javascript:void(0)\">Birinci dönem bitimine 10 gün kaldı.</a>-->\n" +
" <!--<a href=\"javascript:void(0)\">Ders seçimi işlemleri xx tarihinde başlayacaktır.</a>-->\n" +
" <!--</div>-->\n" +
" <!-- end of right-sidebar-status-block -->\n" +
"\n" +
" </div>\n" +
" <!-- end of right-sidebar-status -->\n" +
......@@ -1298,7 +1260,8 @@ angular.module("shared/templates/directives/sidebar.html", []).run(["$templateCa
" </div>\n" +
"\n" +
" <div class=\"sidebar-nav navbar-collapse\">\n" +
" <ul class=\"nav in\" id=\"side-menu\" ng-class=\"{hidden: $root.loggedInUser != true}\">\n" +
" <ul class=\"nav in\" id=\"side-menu\" ng-class=\"{hidden: $root.loggedInUser != true}\" data-step=\"1\"\n" +
" data-intro=\"seçilen personele veya öğrenciye göre ilgili menüler yer almaktadır. yapılacak işlemi buradan seçebilirsiniz.\">\n" +
" <!--<sidebar-search></sidebar-search>-->\n" +
" <li ui-sref-active=\"active\">\n" +
" <a href=\"#/dashboard\" ng-click=\"breadcrumb(['Panel'])\"><i class=\"fa fa-dashboard fa-fw\"></i>\n" +
......@@ -1330,9 +1293,10 @@ angular.module("shared/templates/directives/sidebar.html", []).run(["$templateCa
" </div>\n" +
" <!-- /.sidebar-collapse -->\n" +
"\n" +
"\n" +
" \n" +
" <footer ng-class=\"{hidden: $root.collapsed}\">\n" +
" <a class=\"btn btn-large btn-success\" href=\"javascript:void(0);\" onclick=\"javascript:introJs().setOptions({\n" +
" 'nextLabel': 'Sonraki', 'prevLabel': 'Öncek', 'skipLabel': 'Atla', 'doneLabel': 'Bitir' }).start();\">Yardım\n" +
" Rehberi</a><br>\n" +
" <span>v <app-version></app-version> &copy; ZetaOps</span>\n" +
" </footer>\n" +
"</div>\n" +
......@@ -1570,10 +1534,10 @@ angular.module("shared/templates/listnodeModalContent.html", []).run(["$template
$templateCache.put("shared/templates/listnodeModalContent.html",
"<div class=\"modal-body\">\n" +
" <h3>{{schema.title}}</h3>\n" +
" <form name=\"listnodeform\" sf-schema=\"schema\" sf-form=\"form\" sf-model=\"model\"></form>\n" +
" <form name=\"modalForm\" sf-schema=\"schema\" sf-form=\"form\" sf-model=\"model\" modal-form-locator></form>\n" +
"</div>\n" +
"<div class=\"modal-footer\">\n" +
" <button type=\"submit\" class=\"btn btn-primary\" ng-click=\"onSubmit(listnodeform)\">OK</button>\n" +
" <button type=\"submit\" class=\"btn btn-primary\" ng-click=\"onNodeSubmit()\">OK</button>\n" +
" <button type=\"button\" class=\"btn btn-warning\" ng-click=\"cancel()\">Cancel</button>\n" +
"</div>");
}]);
......
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