Commit 12c7e1d1 authored by Evren Kutar's avatar Evren Kutar

do_action fix

sidebar pinned on cookie
 resolves #49
parent 2742b23c
...@@ -65,13 +65,17 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService']) ...@@ -65,13 +65,17 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
scope[key] = value; scope[key] = value;
}); });
angular.forEach(scope.objects, function (value, key) { angular.forEach(scope.objects, function (value, key) {
if (value!=='-1') { if (key > 0) {
var linkIndexes = {}; var linkIndexes = {};
angular.forEach(value.actions, function (v, k) { angular.forEach(value.actions, function (v, k) {
if (v.show_as === 'link') {linkIndexes = v} if (v.show_as === 'link') {linkIndexes = v}
}); });
angular.forEach(value.fields, function (v, k) { 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']) ...@@ -112,6 +116,18 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
* @returns {object} * @returns {object}
*/ */
.controller('CRUDListFormCtrl', function ($scope, $rootScope, $location, $http, $log, $modal, $timeout, Generator, $routeParams, CrudUtility) { .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') { if ($routeParams.cmd === 'show') {
CrudUtility.generateParam($scope, $routeParams, $routeParams.cmd); CrudUtility.generateParam($scope, $routeParams, $routeParams.cmd);
// todo: refactor createListObjects func // todo: refactor createListObjects func
...@@ -197,13 +213,6 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService']) ...@@ -197,13 +213,6 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
Generator.get_wf($scope); Generator.get_wf($scope);
} }
// 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);
};
}) })
.directive('crudListDirective', function () { .directive('crudListDirective', function () {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
Hepsini Seç Hepsini Seç
</label> </label>
</td> </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 ng-if="objects[0]=='-1'">{{ schema.title||model}}</td>
<td>action</td> <td>action</td>
</tr> </tr>
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<td> <td>
<button class="btn btn-primary" style="margin-right: 5px;" ng-repeat="action in object.actions" <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}} .name}}
</button> </button>
<br> <br>
......
...@@ -130,7 +130,7 @@ app.directive('logout', function ($http, $location, RESTURL) { ...@@ -130,7 +130,7 @@ app.directive('logout', function ($http, $location, RESTURL) {
* toggle collapses sidebar menu when clicked menu button * toggle collapses sidebar menu when clicked menu button
*/ */
.directive('collapseMenu', function ($timeout, $window) { .directive('collapseMenu', function ($timeout, $window, $cookies) {
return { return {
templateUrl: 'shared/templates/directives/menuCollapse.html', templateUrl: 'shared/templates/directives/menuCollapse.html',
restrict: 'E', restrict: 'E',
...@@ -138,7 +138,8 @@ app.directive('logout', function ($http, $location, RESTURL) { ...@@ -138,7 +138,8 @@ app.directive('logout', function ($http, $location, RESTURL) {
scope: {}, scope: {},
controller: function ($scope, $rootScope) { controller: function ($scope, $rootScope) {
$rootScope.collapsed = false; $rootScope.collapsed = false;
$rootScope.sidebarPinned = false; $rootScope.sidebarPinned = $cookies.get('sidebarPinned') || 0;
var cookieSidebar = {1:0,0:1};
$scope.collapseToggle = function () { $scope.collapseToggle = function () {
if ($window.innerWidth > '768') { if ($window.innerWidth > '768') {
...@@ -146,21 +147,24 @@ app.directive('logout', function ($http, $location, RESTURL) { ...@@ -146,21 +147,24 @@ app.directive('logout', function ($http, $location, RESTURL) {
jQuery(".sidebar").css("width", "62px"); jQuery(".sidebar").css("width", "62px");
jQuery(".manager-view").css("width", "calc(100% - 62px)"); jQuery(".manager-view").css("width", "calc(100% - 62px)");
$rootScope.collapsed = true; $rootScope.collapsed = true;
$rootScope.sidebarPinned = false; $rootScope.sidebarPinned = 0;
$cookies.put('sidebarPinned', cookieSidebar[$cookies.get('sidebarPinned')]);
} else { } else {
jQuery("span.menu-text, span.arrow, .sidebar footer").fadeIn(400); jQuery("span.menu-text, span.arrow, .sidebar footer").fadeIn(400);
jQuery(".sidebar").css("width", "250px"); jQuery(".sidebar").css("width", "250px");
jQuery(".manager-view").css("width", "calc(100% - 250px)"); jQuery(".manager-view").css("width", "calc(100% - 250px)");
$rootScope.collapsed = false; $rootScope.collapsed = false;
$rootScope.sidebarPinned = true; $rootScope.sidebarPinned = 1;
$cookies.put('sidebarPinned', cookieSidebar[$cookies.get('sidebarPinned')]);
} }
} }
}; };
$timeout(function () { $timeout(function () {
$scope.collapseToggle(); if ($cookies.get('sidebarPinned') === "0") {
$scope.collapseToggle();
}
}); });
} }
}; };
...@@ -287,7 +291,7 @@ app.directive('logout', function ($http, $location, RESTURL) { ...@@ -287,7 +291,7 @@ app.directive('logout', function ($http, $location, RESTURL) {
$scope.openSidebar = function () { $scope.openSidebar = function () {
if ($window.innerWidth > '768') { 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("span.menu-text, span.arrow, .sidebar footer, #side-menu").fadeIn(400);
jQuery(".sidebar").css("width", "250px"); jQuery(".sidebar").css("width", "250px");
jQuery(".manager-view").css("width", "calc(100% - 250px)"); jQuery(".manager-view").css("width", "calc(100% - 250px)");
...@@ -298,7 +302,7 @@ app.directive('logout', function ($http, $location, RESTURL) { ...@@ -298,7 +302,7 @@ app.directive('logout', function ($http, $location, RESTURL) {
$scope.closeSidebar = function () { $scope.closeSidebar = function () {
if ($window.innerWidth > '768') { if ($window.innerWidth > '768') {
if ($rootScope.sidebarPinned === false) { if ($rootScope.sidebarPinned === 0) {
jQuery(".sidebar").css("width", "62px"); jQuery(".sidebar").css("width", "62px");
jQuery(".manager-view").css("width", "calc(100% - 62px)"); jQuery(".manager-view").css("width", "calc(100% - 62px)");
$rootScope.collapsed = true; $rootScope.collapsed = true;
......
...@@ -88,29 +88,19 @@ angular.module('formService', []) ...@@ -88,29 +88,19 @@ angular.module('formService', [])
return formObject; return formObject;
}; };
/** /**
* @name prepareFormItems
* @description
* prepareFormItems looks up fields of schema objects and changes their types to proper type for schemaform * 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 * for listnode, node and model types it uses templates to generate modal
* prepareforms checks input types and convert if necessary
*
* @param scope * @param scope
* @returns {*} * @returns {*}
*/ */
generator.prepareFormItems = function (scope) { 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) { angular.forEach(scope.schema.properties, function (v, k) {
// generically change _id fields model value // generically change _id fields model value
if ('form_params' in scope) { if ('form_params' in scope) {
if (k == scope.form_params.param) { if (k == scope.form_params.param) {
scope.model[k] = scope.form_params.id; scope.model[k] = scope.form_params.id;
...@@ -210,10 +200,10 @@ angular.module('formService', []) ...@@ -210,10 +200,10 @@ angular.module('formService', [])
titleMap: generator.get_list(modelscope).then(function (res) { titleMap: generator.get_list(modelscope).then(function (res) {
formitem.titleMap = []; formitem.titleMap = [];
angular.forEach(res.data.objects, function (item) { angular.forEach(res.data.objects, function (item) {
if (item !== res.data.objects[0]) { if (item !== "-1") {
formitem.titleMap.push({ formitem.titleMap.push({
"value": item[0], "value": item.key,
"name": item[1] + ' ' + (item[2] ? item[2] : '') + '...' "name": item.value
}); });
} }
}); });
...@@ -301,6 +291,7 @@ angular.module('formService', []) ...@@ -301,6 +291,7 @@ angular.module('formService', [])
$scope.form_params.object_id = key; $scope.form_params.object_id = key;
$scope.form_params.param = $scope.param; $scope.form_params.param = $scope.param;
$scope.form_params.id = $scope.param_id; $scope.form_params.id = $scope.param_id;
$scope.form_params.token = $scope.token;
generator.get_wf($scope); generator.get_wf($scope);
}; };
...@@ -318,7 +309,7 @@ angular.module('formService', []) ...@@ -318,7 +309,7 @@ angular.module('formService', [])
*/ */
generator.get_list = function (scope) { generator.get_list = function (scope) {
return $http return $http
.get(generator.makeUrl(scope)) .post(generator.makeUrl(scope), scope.form_params)
.then(function (res) { .then(function (res) {
return res; return res;
}); });
...@@ -390,6 +381,7 @@ angular.module('formService', []) ...@@ -390,6 +381,7 @@ angular.module('formService', [])
* @param data * @param data
*/ */
generator.pathDecider = function (client_cmd, $scope, 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 * @name redirectTo
* @description * @description
......
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) { angular.module("components/auth/login.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("components/auth/login.html", $templateCache.put("components/auth/login.html",
...@@ -90,7 +90,7 @@ angular.module("components/crud/templates/list.html", []).run(["$templateCache", ...@@ -90,7 +90,7 @@ angular.module("components/crud/templates/list.html", []).run(["$templateCache",
" Hepsini Seç\n" + " Hepsini Seç\n" +
" </label>\n" + " </label>\n" +
" </td>\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 ng-if=\"objects[0]=='-1'\">{{ schema.title||model}}</td>\n" +
" <td>action</td>\n" + " <td>action</td>\n" +
" </tr>\n" + " </tr>\n" +
...@@ -113,7 +113,7 @@ angular.module("components/crud/templates/list.html", []).run(["$templateCache", ...@@ -113,7 +113,7 @@ angular.module("components/crud/templates/list.html", []).run(["$templateCache",
"\n" + "\n" +
" <td>\n" + " <td>\n" +
" <button class=\"btn btn-primary\" style=\"margin-right: 5px;\" ng-repeat=\"action in object.actions\"\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" + " .name}}\n" +
" </button>\n" + " </button>\n" +
" <br>\n" + " <br>\n" +
...@@ -1508,6 +1508,28 @@ angular.module("shared/templates/modalContent.html", []).run(["$templateCache", ...@@ -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) { angular.module("shared/templates/nodeTable.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("shared/templates/nodeTable.html", $templateCache.put("shared/templates/nodeTable.html",
"<div class=\"tablescroll\">\n" + "<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