WIP open file for a while
This commit is contained in:
parent
f937019e42
commit
d280fb9af3
122 changed files with 5702 additions and 10 deletions
|
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
tcrudUI.controller('ApplicationController',function($scope,$http,$location,navigationService) {
|
||||
console.log('start menu controller');
|
||||
$scope.goLink = function ( path ) {
|
||||
$location.path( path );
|
||||
};
|
||||
$scope.navigationService = navigationService;
|
||||
$scope.applicationMenu = {};
|
||||
$http.get('<%= troot.tmeta.tserver.tslugs.tbase %>/<%= troot.tmeta.tserver.tslugs.tserver %>/config/menu').success(function(data, status, headers, config) {
|
||||
$scope.applicationMenu = data.data;
|
||||
$scope.applicationMenuKeys = Object.keys(data.data);
|
||||
});
|
||||
});
|
||||
15
lib/www_views/node-ff-tcrud/angular/js/application-font.ejs
Normal file
15
lib/www_views/node-ff-tcrud/angular/js/application-font.ejs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
console.log('FFTCrudExample.fontFaceOnload check');
|
||||
var ffolStartTime = new Date().getTime();
|
||||
FontFaceOnload('Source Sans', {
|
||||
timeout: 1234,
|
||||
success: function() {
|
||||
console.log('FFTCrudExample.FontFaceOnload success in '+(new Date().getTime()-ffolStartTime)+' ms.');
|
||||
document.documentElement.className += ' fontLoaded';
|
||||
},
|
||||
error: function() {
|
||||
console.log('FFTCrudExample.fontFaceOnload timeout.');
|
||||
document.documentElement.className += ' fontLoaded';
|
||||
}
|
||||
});
|
||||
26
lib/www_views/node-ff-tcrud/angular/js/application.ejs
Normal file
26
lib/www_views/node-ff-tcrud/angular/js/application.ejs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
var serverUrl = window.FFServerUrl;
|
||||
var crudRouteInit = [];
|
||||
var pageRouteInit = [];
|
||||
|
||||
document.title = 'TCrud Example';
|
||||
|
||||
$(document.createElement('div')).attr('ng-controller', 'ApplicationController').attr('ng-include','\''+serverUrl+'/api/plugin/angular/thtml/application-top\'').appendTo($('body'));
|
||||
$(document.createElement('div')).attr('ng-include','\''+serverUrl+'/api/plugin/angular/thtml/application-view\'').appendTo($('body'));
|
||||
|
||||
var tcrudUI = angular.module('tcrudUI', ['ngRoute','ngTouch','ngAnimate', 'ui.grid', 'ui.grid.pagination','ui.grid.cellNav', 'ui.grid.edit', 'ui.grid.resizeColumns', 'ui.grid.pinning', 'ui.grid.selection', 'ui.grid.moveColumns', 'ui.grid.exporter', 'ui.grid.importer', 'ui.grid.grouping', 'ui.grid.autoResize']).
|
||||
config(['$routeProvider', '$locationProvider', '$sceDelegateProvider', function($routeProvider, $locationProvider, $sceDelegateProvider) {
|
||||
|
||||
// init routes
|
||||
pageRouteInit.forEach(function(init) { init($routeProvider, $locationProvider); });
|
||||
crudRouteInit.forEach(function(init) { init($routeProvider, $locationProvider); });
|
||||
|
||||
$sceDelegateProvider.resourceUrlWhitelist(['self',serverUrl+'/**']);
|
||||
$routeProvider.otherwise({ redirectTo: '/ui' });
|
||||
$locationProvider.html5Mode({requireBase: false});
|
||||
}]);
|
||||
|
||||
tcrudUI.run(['$route', function($route) {
|
||||
$route.reload(); // ng-view works inside the ng-include
|
||||
}]);
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
$scope.<%= taction %>None = function () {
|
||||
<% if (tview.tlist) { %>
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tlist.tplugin.angular.tslug %>');
|
||||
<% } else { %>
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/');
|
||||
<% } %>
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
$routeProvider.when('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview[taction].tplugin.angular.tslug %><%= routeEnd %>', {
|
||||
templateUrl: '<%= thtmlPrefix %>/<%= tview[taction].tplugin.angular.thtml %>',
|
||||
controller: <%= tview[taction].tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview[taction].tplugin.angular.tcontroller.postfix %>
|
||||
});
|
||||
173
lib/www_views/node-ff-tcrud/angular/js/crud/controller.ejs
Normal file
173
lib/www_views/node-ff-tcrud/angular/js/crud/controller.ejs
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
'use strict';
|
||||
|
||||
//
|
||||
// Auto generated controller mapping for: <%= tview.tid %>
|
||||
//
|
||||
|
||||
crudRouteInit.push(auto<%= tviewCode %>Init);
|
||||
|
||||
function auto<%= tviewCode %>Init($routeProvider, $locationProvider) {
|
||||
<% if (tview.tlist) { %>
|
||||
$routeProvider.when('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/', {
|
||||
redirectTo: '<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tlist.tplugin.angular.tslug %>'
|
||||
});
|
||||
<%- include('controller-route', {tview: tview,tviewCode: tviewCode,thtmlPrefix:thtmlPrefix,taction: 'tlist', routeEnd: ''}); %>
|
||||
<% } %>
|
||||
<% if (tview.tcreate) { %>
|
||||
<%- include('controller-route', {tview: tview,tviewCode: tviewCode,thtmlPrefix:thtmlPrefix,taction: 'tcreate', routeEnd: ''}); %>
|
||||
<% } %>
|
||||
<% if (tview.tedit) { %>
|
||||
<%- include('controller-route', {tview: tview,tviewCode: tviewCode,thtmlPrefix:thtmlPrefix,taction: 'tedit', routeEnd: '/'+tview.tmeta.tmodel.tkey}); %>
|
||||
<% } %>
|
||||
<% if (tview.tread) { %>
|
||||
<%- include('controller-route', {tview: tview,tviewCode: tviewCode,thtmlPrefix:thtmlPrefix,taction: 'tread', routeEnd: '/'+tview.tmeta.tmodel.tkey}); %>
|
||||
<% } %>
|
||||
<% if (tview.tdelete) { %>
|
||||
<%- include('controller-route', {tview: tview,tviewCode: tviewCode,thtmlPrefix:thtmlPrefix,taction: 'tdelete', routeEnd: '/'+tview.tmeta.tmodel.tkey}); %>
|
||||
<% } %>
|
||||
}
|
||||
|
||||
<% if (tview.tlist) { %>
|
||||
function <%= tview.tlist.tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview.tlist.tplugin.angular.tcontroller.postfix %>(<%= tview.tlist.tplugin.angular.tcontroller.argu %>) {
|
||||
|
||||
$scope.uiTableMain = {};
|
||||
$scope.uiTableMain.enableColumnResizing = true;
|
||||
$scope.uiTableMain.enableFiltering = false;
|
||||
$scope.uiTableMain.enableGridMenu = true;
|
||||
$scope.uiTableMain.showGridFooter = false;
|
||||
$scope.uiTableMain.showColumnFooter = false;
|
||||
$scope.uiTableMain.paginationPageSizes = [25, 50, 75];
|
||||
$scope.uiTableMain.paginationPageSize = 25;
|
||||
$scope.uiTableMain.enableFullRowSelection = true;
|
||||
$scope.uiTableMain.multiSelect = false;
|
||||
$scope.uiTableMain.columnDefs = [];
|
||||
|
||||
$scope.uiTableMain.onRegisterApi = function(gridApi){
|
||||
$scope.gridApi = gridApi;
|
||||
|
||||
gridApi.selection.on.rowSelectionChanged($scope,function(row) {
|
||||
if ($scope.gridApi.selection.getSelectedRows().length > 0) {
|
||||
navigationService.actions.open = $scope.doEdit;
|
||||
} else {
|
||||
navigationService.actions.open = null;
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
var fetchData = function() {
|
||||
$http.get('<%= tapiPrefix %>/<%= tview.tlist.tplugin.formatJSON.tslug %>').success(function(data, status, headers, config) {
|
||||
$scope.uiTableMain.data = data.data;
|
||||
});
|
||||
};
|
||||
|
||||
navigationService.actions.refresh = function() {
|
||||
fetchData();
|
||||
};
|
||||
navigationService.actions.create = function() {
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tcreate.tplugin.angular.tslug %>');
|
||||
};
|
||||
$scope.doEdit = function() {
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tedit.tplugin.angular.tslug %>/'+$scope.gridApi.selection.getSelectedRows()[0].country_id);
|
||||
};
|
||||
|
||||
$http.get('<%= tapiPrefix2 %>').success(function(data, status, headers, config) {
|
||||
var tview = data.data.tview;
|
||||
tview.tlist.tfields.forEach(function (fieldKey) {
|
||||
var field = tview.tmeta.tfields[fieldKey];
|
||||
$scope.uiTableMain.columnDefs.push({
|
||||
name: field.tname,
|
||||
field: field.tid,
|
||||
type2: field.ttype,
|
||||
});
|
||||
});
|
||||
navigationService.pageTitle = tview.tname;
|
||||
fetchData();
|
||||
});
|
||||
}
|
||||
<% } %>
|
||||
|
||||
<% if (tview.tcreate) { %>
|
||||
function <%= tview.tcreate.tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview.tcreate.tplugin.angular.tcontroller.postfix %>(<%= tview.tcreate.tplugin.angular.tcontroller.argu %>) {
|
||||
$scope.data = {};
|
||||
$scope.tcreateData = function () {
|
||||
$http.post('<%= tapiPrefix %>/<%= tview.tcreate.tplugin.formatJSON.tslug %>', $scope.data).success(function(data) {
|
||||
<% if (tview.tlist) { %>
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tlist.tplugin.angular.tslug %>');
|
||||
<% } else { %>
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/');
|
||||
<% } %>
|
||||
});
|
||||
}
|
||||
<%- include('controller-action-none', {tview: tview,taction: 'tcreate'}); %>
|
||||
}
|
||||
<% } %>
|
||||
|
||||
<% if (tview.tread) { %>
|
||||
function <%= tview.tread.tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview.tread.tplugin.angular.tcontroller.postfix %>(<%= tview.tread.tplugin.angular.tcontroller.argu %>) {
|
||||
$scope.data = {};
|
||||
$http.get('<%= tapiPrefix %>/<%= tview.tread.tplugin.formatJSON.tslug %>/' + <%= ejsRouteParams %>).success(function(data) {
|
||||
$scope.data = data.data;
|
||||
});
|
||||
<%- include('controller-action-none', {tview: tview,taction: 'tread'}); %>
|
||||
}
|
||||
<% } %>
|
||||
|
||||
<% if (tview.tedit) { %>
|
||||
function <%= tview.tedit.tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview.tedit.tplugin.angular.tcontroller.postfix %>(<%= tview.tedit.tplugin.angular.tcontroller.argu %>) {
|
||||
$scope.data = {};
|
||||
var fetchData = function() {
|
||||
$http.get('<%= tapiPrefix %>/<%= tview.tread.tplugin.formatJSON.tslug %>/' + <%= ejsRouteParams %>).success(function(data) {
|
||||
$scope.data = data.data;
|
||||
});
|
||||
};
|
||||
fetchData();
|
||||
|
||||
$scope.teditData = function () {
|
||||
$http.put('<%= tapiPrefix %>/<%= tview.tedit.tplugin.formatJSON.tslug %>/' + <%= ejsRouteParams %>, $scope.data ).success(function(data) {
|
||||
<% if (tview.tread) { %>
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tread.tplugin.angular.tslug %>/' + <%= ejsRouteParams %>);
|
||||
<% } else { %>
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/');
|
||||
<% } %>
|
||||
});
|
||||
}
|
||||
$scope.tdeleteData = function () {
|
||||
$http.delete('<%= tapiPrefix %>/<%= tview.tdelete.tplugin.formatJSON.tslug %>/'+ <%= ejsRouteParams %>, $scope.data).success(function(data) {
|
||||
<% if (tview.tlist) { %>
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tlist.tplugin.angular.tslug %>');
|
||||
<% } else { %>
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/');
|
||||
<% } %>
|
||||
});
|
||||
}
|
||||
<%- include('controller-action-none', {tview: tview,taction: 'tedit'}); %>
|
||||
|
||||
navigationService.actions.save = $scope.teditData;
|
||||
navigationService.actions.cancel = $scope.teditNone;
|
||||
navigationService.actions.delete = $scope.tdeleteData;
|
||||
navigationService.actions.refresh = function() {
|
||||
fetchData();
|
||||
};
|
||||
}
|
||||
<% } %>
|
||||
|
||||
<% if (tview.tdelete) { %>
|
||||
function <%= tview.tdelete.tplugin.angular.tcontroller.prefix %><%= tviewCode %><%= tview.tdelete.tplugin.angular.tcontroller.postfix %>(<%= tview.tdelete.tplugin.angular.tcontroller.argu %>) {
|
||||
$scope.data = {};
|
||||
$http.get('<%= tapiPrefix %>/<%= tview.tread.tplugin.formatJSON.tslug %>/' + <%= ejsRouteParams %>).success(function(data) {
|
||||
$scope.data = data.data;
|
||||
console.log('delete obj: '+JSON.stringify(data.data));
|
||||
});
|
||||
$scope.tdeleteData = function () {
|
||||
$http.delete('<%= tapiPrefix %>/<%= tview.tdelete.tplugin.formatJSON.tslug %>/'+ <%= ejsRouteParams %>, $scope.data).success(function(data) {
|
||||
<% if (tview.tlist) { %>
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/<%= tview.tslug %>/<%= tview.tlist.tplugin.angular.tslug %>');
|
||||
<% } else { %>
|
||||
$location.url('<%= tview.tmeta.tplugin.angular.tbase %>/');
|
||||
<% } %>
|
||||
});
|
||||
}
|
||||
<%- include('controller-action-none', {tview: tview,taction: 'tdelete'}); %>
|
||||
}
|
||||
<% } %>
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
'use strict';
|
||||
|
||||
tcrudUI.factory('navigationService', ['$route', '$rootScope',
|
||||
function($route, $rootScope) {
|
||||
|
||||
var actions = {
|
||||
save: null,
|
||||
cancel: null,
|
||||
open: null,
|
||||
delete: null,
|
||||
create: null,
|
||||
refresh: null
|
||||
};
|
||||
var resetActions = function() {
|
||||
for (var key in actions) {
|
||||
if (key.indexOf('Impl') > 0) {
|
||||
continue;
|
||||
}
|
||||
actions[key] = null;
|
||||
}
|
||||
};
|
||||
actions.saveImpl = function() {
|
||||
actions.save();
|
||||
resetActions();
|
||||
};
|
||||
actions.cancelImpl = function() {
|
||||
actions.cancel();
|
||||
resetActions();
|
||||
};
|
||||
actions.openImpl = function() {
|
||||
actions.open();
|
||||
resetActions();
|
||||
};
|
||||
actions.deleteImpl = function() {
|
||||
actions.delete();
|
||||
resetActions();
|
||||
};
|
||||
|
||||
var pageTabs = [];
|
||||
var pageTitle = '';
|
||||
var pageLocations = [];
|
||||
|
||||
$rootScope.$on('$routeChangeSuccess', function() {
|
||||
pageTabs = [];
|
||||
pageTitle = '';
|
||||
pageLocations = [];
|
||||
resetActions(); // to late gives flikering..
|
||||
//$rootScope.$apply();
|
||||
});
|
||||
return {
|
||||
actions: actions,
|
||||
pageTabs: pageTabs,
|
||||
pageTitle: pageTitle,
|
||||
pageLocations: pageLocations,
|
||||
};
|
||||
}
|
||||
]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue