12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- angular.module('app')
- .controller('PkGuidEditController', ['$scope', '$state', '$mdDialog', 'pkGuidBusiness', 'AppUtilsBusiness', 'luBusyBusiness',
- function ($scope, $state, $mdDialog, pkGuidBusiness, AppUtilsBusiness, luBusyBusiness) {
-
- $scope.pkguid = null;
- $scope.defaultPkguid = {
- id: null,
- someText: "Test.",
- someInt: 42
- };
-
- $scope.busy = luBusyBusiness.reset();
- $scope.appUtils = AppUtilsBusiness;
-
- $scope.setTitle = function()
- {
- if ($scope.pkguid.id != null) {
- AppUtilsBusiness.setTitle(AppUtilsBusiness.tr('pkguid.edit.title', {text: $scope.pkguid.someText}));
- AppUtilsBusiness.setToolbarTitle(AppUtilsBusiness.tr('pkguid.edit.toolbarTitle', {text: $scope.pkguid.someText}));
- }
- };
-
- $scope.submit = function () {
- if ($scope.pkguid.id == null) {
- pkGuidBusiness.addDbo($scope.pkguid, 'pkguid.edit').then(function (data) {
- $scope.pkguid = data;
- $state.go('pkguid_edit', {pkguid: $scope.pkguid, id: $scope.pkguid.id});
- }, function (error) {});
- }
- else {
- pkGuidBusiness.editSingleByIdDbo($scope.pkguid.id, $scope.pkguid, 'pkguid.edit').then(function (data) {
- $scope.pkguid = data;
- $scope.setTitle();
- }, function (error) {});
- }
- };
-
-
- if ($state.params != null) {
- if ($state.params.pkguid != null) {
- $scope.pkguid = $state.params.pkguid;
- $scope.setTitle();
- }
- else if ($state.params.id != null) {
- pkGuidBusiness.getSingleById($state.params.id, 'pkguid.edit').then(function(data)
- {
- $scope.pkguid = data;
- $scope.setTitle();
- }, function (error) {
- $scope.pkguid = null;
- $scope.setTitle();
- });
- }
- else {
- $scope.pkguid = angular.copy($scope.defaultPkguid);
- $scope.setTitle();
- }
- }
- else {
- $scope.pkguid = angular.copy($scope.defaultPkguid);
- $scope.setTitle();
- }
-
- }]);
|