Commit dbdcc682 authored by Evren Kutar's avatar Evren Kutar

resolves #48

Merge branch 'Feature/issue48'
parents dc7c64f9 12c7e1d1
......@@ -65,13 +65,17 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
scope[key] = value;
});
angular.forEach(scope.objects, function (value, key) {
if (value!=='-1') {
if (key > 0) {
var linkIndexes = {};
angular.forEach(value.actions, function (v, k) {
if (v.show_as === 'link') {linkIndexes = v}
});
angular.forEach(value.fields, function (v, k) {
scope.objects[key].fields[k] = {type: linkIndexes.fields.indexOf(k) > -1 ? 'link' : 'str', content: v, cmd: linkIndexes.cmd};
if (value.actions.length > 0 && linkIndexes.fields){
scope.objects[key].fields[k] = {type: linkIndexes.fields.indexOf(k) > -1 ? 'link' : 'str', content: v, cmd: linkIndexes.cmd};
} else {
scope.objects[key].fields[k] = {type: 'str', content: v};
}
});
}
});
......@@ -112,6 +116,18 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
* @returns {object}
*/
.controller('CRUDListFormCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams, CrudUtility) {
// reloadData must be a json object
$scope.reload = function (reloadData) {
$scope.form_params.cmd = $scope.reload_cmd;
$scope.form_params = angular.extend($scope.form_params, reloadData);
$log.debug('reload data', $scope);
Generator.get_wf($scope);
};
$scope.$on('reload_cmd', function(event, data){
$scope.reload_cmd = data;
$scope.reload({});
});
if ($routeParams.cmd === 'show') {
CrudUtility.generateParam($scope, $routeParams, $routeParams.cmd);
// todo: refactor createListObjects func
......@@ -182,24 +198,13 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
Generator.doItemAction($scope, key, cmd);
};
$scope.pagination = {page:1, total_pages:8};
$scope.getNumber = function (num) {
return new Array(num);
};
// reloadData must be a json object
$scope.reload = function (reloadData) {
$scope.form_params.cmd = $scope.reload_cmd;
$scope.form_params = angular.extend($scope.form_params, reloadData);
$log.debug('reload data', $scope);
Generator.get_wf($scope);
};
}
if ($routeParams.cmd === 'reload') {
$scope.cmd = 'reload';
Generator.get_wf($scope);
$scope.reload({});
}
if ($routeParams.cmd === 'reset') {
......@@ -207,6 +212,7 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
$scope.cmd = 'reset';
Generator.get_wf($scope);
}
})
.directive('crudListDirective', function () {
......
......@@ -17,7 +17,7 @@
Hepsini Seç
</label>
</td>
<td ng-repeat="value in objects[0]" ng-if="objects[0]!='-1'">{{values }}</td>
<td ng-repeat="value in objects[0]" ng-if="objects[0]!='-1'">{{value}}</td>
<td ng-if="objects[0]=='-1'">{{ schema.title||model}}</td>
<td>action</td>
</tr>
......@@ -40,7 +40,7 @@
<td>
<button class="btn btn-primary" style="margin-right: 5px;" ng-repeat="action in object.actions"
ng-if="action.show_as==='button'" ng-click="do_action(object.key, action)">{{action
ng-if="action.show_as==='button'" ng-click="do_action(object.key, action.cmd)">{{action
.name}}
</button>
<br>
......
......@@ -130,7 +130,7 @@ app.directive('logout', function ($http, $location, RESTURL) {
* toggle collapses sidebar menu when clicked menu button
*/
.directive('collapseMenu', function ($timeout, $window) {
.directive('collapseMenu', function ($timeout, $window, $cookies) {
return {
templateUrl: 'shared/templates/directives/menuCollapse.html',
restrict: 'E',
......@@ -138,7 +138,8 @@ app.directive('logout', function ($http, $location, RESTURL) {
scope: {},
controller: function ($scope, $rootScope) {
$rootScope.collapsed = false;
$rootScope.sidebarPinned = false;
$rootScope.sidebarPinned = $cookies.get('sidebarPinned') || 0;
var cookieSidebar = {1:0,0:1};
$scope.collapseToggle = function () {
if ($window.innerWidth > '768') {
......@@ -146,21 +147,24 @@ app.directive('logout', function ($http, $location, RESTURL) {
jQuery(".sidebar").css("width", "62px");
jQuery(".manager-view").css("width", "calc(100% - 62px)");
$rootScope.collapsed = true;
$rootScope.sidebarPinned = false;
$rootScope.sidebarPinned = 0;
$cookies.put('sidebarPinned', cookieSidebar[$cookies.get('sidebarPinned')]);
} else {
jQuery("span.menu-text, span.arrow, .sidebar footer").fadeIn(400);
jQuery(".sidebar").css("width", "250px");
jQuery(".manager-view").css("width", "calc(100% - 250px)");
$rootScope.collapsed = false;
$rootScope.sidebarPinned = true;
$rootScope.sidebarPinned = 1;
$cookies.put('sidebarPinned', cookieSidebar[$cookies.get('sidebarPinned')]);
}
}
};
$timeout(function () {
$scope.collapseToggle();
if ($cookies.get('sidebarPinned') === "0") {
$scope.collapseToggle();
}
});
}
};
......@@ -287,7 +291,7 @@ app.directive('logout', function ($http, $location, RESTURL) {
$scope.openSidebar = function () {
if ($window.innerWidth > '768') {
if ($rootScope.sidebarPinned === false) {
if ($rootScope.sidebarPinned === 0) {
jQuery("span.menu-text, span.arrow, .sidebar footer, #side-menu").fadeIn(400);
jQuery(".sidebar").css("width", "250px");
jQuery(".manager-view").css("width", "calc(100% - 250px)");
......@@ -298,7 +302,7 @@ app.directive('logout', function ($http, $location, RESTURL) {
$scope.closeSidebar = function () {
if ($window.innerWidth > '768') {
if ($rootScope.sidebarPinned === false) {
if ($rootScope.sidebarPinned === 0) {
jQuery(".sidebar").css("width", "62px");
jQuery(".manager-view").css("width", "calc(100% - 62px)");
$rootScope.collapsed = true;
......
......@@ -88,29 +88,19 @@ angular.module('formService', [])
return formObject;
};
/**
* @name prepareFormItems
* @description
* prepareFormItems looks up fields of schema objects and changes their types to proper type for schemaform
* for listnode, node and model types it uses templates to generate modal
* prepareforms checks input types and convert if necessary
*
* @param scope
* @returns {*}
*/
generator.prepareFormItems = function (scope) {
/**
* prepareforms checks input types and convert if necessary
*/
// todo: remove after backend fix
//angular.forEach(scope.form, function (value, key) {
// if (value.type === 'select') {
// scope.schema.properties[value.key].type = 'select';
// scope.schema.properties[value.key].titleMap = value.titleMap;
// scope.form[key] = value.key;
// }
//});
angular.forEach(scope.schema.properties, function (v, k) {
// generically change _id fields model value
if ('form_params' in scope) {
if (k == scope.form_params.param) {
scope.model[k] = scope.form_params.id;
......@@ -197,21 +187,23 @@ angular.module('formService', [])
if (v.type === 'model') {
var formitem = scope.form[scope.form.indexOf(k)];
var modelscope = {"url": scope.url, "form_params": {model: v.model_name}};
var modelscope = {"url": v.wf, "form_params": {model: v.model_name, cmd: v.list_cmd}};
formitem = {
type: "template",
templateUrl: "shared/templates/foreignKey.html",
title: v.title,
wf: v.wf,
add_cmd: v.add_cmd,
name: v.model_name,
model_name: v.model_name,
titleMap: generator.get_list(modelscope).then(function (res) {
formitem.titleMap = [];
angular.forEach(res.data.objects, function (item) {
if (item !== res.data.objects[0]) {
if (item !== "-1") {
formitem.titleMap.push({
"value": item[0],
"name": item[1] + ' ' + (item[2] ? item[2] : '') + '...'
"value": item.key,
"name": item.value
});
}
});
......@@ -299,6 +291,7 @@ angular.module('formService', [])
$scope.form_params.object_id = key;
$scope.form_params.param = $scope.param;
$scope.form_params.id = $scope.param_id;
$scope.form_params.token = $scope.token;
generator.get_wf($scope);
};
......@@ -316,7 +309,7 @@ angular.module('formService', [])
*/
generator.get_list = function (scope) {
return $http
.get(generator.makeUrl(scope))
.post(generator.makeUrl(scope), scope.form_params)
.then(function (res) {
return res;
});
......@@ -388,6 +381,7 @@ angular.module('formService', [])
* @param data
*/
generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {$rootScope.$broadcast('reload_cmd', client_cmd[0]); return;}
/**
* @name redirectTo
* @description
......@@ -597,15 +591,15 @@ angular.module('formService', [])
resolve: {
items: function () {
return Generator.get_form({
url: 'crud',
form_params: {'model': scope.form.model_name, "cmd": "form"}
url: scope.form.wf,
form_params: {model: scope.form.model_name, cmd: scope.form.add_cmd}
});
}
}
});
modalInstance.result.then(function (childmodel, key) {
Generator.submit(childmodel);
modalInstance.result.then(function (childscope, key) {
Generator.submit(childscope);
$route.reload();
});
});
......
This diff is collapsed.
This diff is collapsed.
angular.module('templates-prod', ['components/auth/login.html', 'components/crud/templates/crud.html', 'components/crud/templates/form.html', 'components/crud/templates/list.html', 'components/crud/templates/show.html', 'components/dashboard/dashboard.html', 'components/debug/debug.html', 'components/devSettings/devSettings.html', 'components/error_pages/404.html', 'components/error_pages/500.html', 'components/uitemplates/404.html', 'components/uitemplates/500.html', 'shared/templates/add.html', 'shared/templates/datefield.html', 'shared/templates/directives/chat.html', 'shared/templates/directives/header-breadcrumb.html', 'shared/templates/directives/header-notification.html', 'shared/templates/directives/header-sub-menu.html', 'shared/templates/directives/menuCollapse.html', 'shared/templates/directives/msgbox.html', 'shared/templates/directives/notifications.html', 'shared/templates/directives/search.html', 'shared/templates/directives/selected-user.html', 'shared/templates/directives/sidebar-notification.html', 'shared/templates/directives/sidebar-search.html', 'shared/templates/directives/sidebar.html', 'shared/templates/directives/stats.html', 'shared/templates/directives/timeline.html', 'shared/templates/fieldset.html', 'shared/templates/foreignKey.html', 'shared/templates/linkedModelModalContent.html', 'shared/templates/listnodeModalContent.html', 'shared/templates/modalContent.html', 'shared/templates/nodeTable.html', 'shared/templates/select.html']);
angular.module('templates-prod', ['components/auth/login.html', 'components/crud/templates/crud.html', 'components/crud/templates/form.html', 'components/crud/templates/list.html', 'components/crud/templates/show.html', 'components/dashboard/dashboard.html', 'components/debug/debug.html', 'components/devSettings/devSettings.html', 'components/error_pages/404.html', 'components/error_pages/500.html', 'components/uitemplates/404.html', 'components/uitemplates/500.html', 'shared/templates/add.html', 'shared/templates/datefield.html', 'shared/templates/directives/chat.html', 'shared/templates/directives/header-breadcrumb.html', 'shared/templates/directives/header-notification.html', 'shared/templates/directives/header-sub-menu.html', 'shared/templates/directives/menuCollapse.html', 'shared/templates/directives/msgbox.html', 'shared/templates/directives/notifications.html', 'shared/templates/directives/search.html', 'shared/templates/directives/selected-user.html', 'shared/templates/directives/sidebar-notification.html', 'shared/templates/directives/sidebar-search.html', 'shared/templates/directives/sidebar.html', 'shared/templates/directives/stats.html', 'shared/templates/directives/timeline.html', 'shared/templates/fieldset.html', 'shared/templates/foreignKey.html', 'shared/templates/linkedModelModalContent.html', 'shared/templates/listnodeModalContent.html', 'shared/templates/modalContent.html', 'shared/templates/multiselect.html', 'shared/templates/nodeTable.html', 'shared/templates/select.html']);
angular.module("components/auth/login.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("components/auth/login.html",
......@@ -90,7 +90,7 @@ angular.module("components/crud/templates/list.html", []).run(["$templateCache",
" Hepsini Seç\n" +
" </label>\n" +
" </td>\n" +
" <td ng-repeat=\"value in objects[0]\" ng-if=\"objects[0]!='-1'\">{{values }}</td>\n" +
" <td ng-repeat=\"value in objects[0]\" ng-if=\"objects[0]!='-1'\">{{value}}</td>\n" +
" <td ng-if=\"objects[0]=='-1'\">{{ schema.title||model}}</td>\n" +
" <td>action</td>\n" +
" </tr>\n" +
......@@ -113,7 +113,7 @@ angular.module("components/crud/templates/list.html", []).run(["$templateCache",
"\n" +
" <td>\n" +
" <button class=\"btn btn-primary\" style=\"margin-right: 5px;\" ng-repeat=\"action in object.actions\"\n" +
" ng-if=\"action.show_as==='button'\" ng-click=\"do_action(object.key, action)\">{{action\n" +
" ng-if=\"action.show_as==='button'\" ng-click=\"do_action(object.key, action.cmd)\">{{action\n" +
" .name}}\n" +
" </button>\n" +
" <br>\n" +
......@@ -1508,6 +1508,28 @@ angular.module("shared/templates/modalContent.html", []).run(["$templateCache",
"");
}]);
angular.module("shared/templates/multiselect.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("shared/templates/multiselect.html",
"<div class=\"form-group {{form.htmlClass}} schema-form-select\"\n" +
" ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess(), 'has-feedback': form.feedback !== false}\">\n" +
" <label class=\"control-label {{form.labelHtmlClass}}\" ng-show=\"showTitle()\">\n" +
" {{form.title}}\n" +
" </label>\n" +
" <select ng-model=\"$$value$$\"\n" +
" ng-model-options=\"form.ngModelOptions\"\n" +
" ng-disabled=\"form.readonly\"\n" +
" sf-changed=\"form\"\n" +
" class=\"form-control {{form.fieldHtmlClass}}\"\n" +
" schema-validate=\"form\"\n" +
" ng-options=\"item.value as item.name for item in form.titleMap\"\n" +
" name=\"{{form.key.slice(-1)[0]}}\"\n" +
" id=\"{{form.key.slice(-1)[0]}}\" multiple>\n" +
" </select>\n" +
"\n" +
" <div class=\"help-block\" sf-message=\"form.description\"></div>\n" +
"</div>");
}]);
angular.module("shared/templates/nodeTable.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("shared/templates/nodeTable.html",
"<div class=\"tablescroll\">\n" +
......
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