@@ -49,113 +49,6 @@
-
-
-
- カテゴリ2
-
-
-
-
-
-
- element('content_move_btn', array('size' => '12 col-md-1')); ?>
-
-
-
- element('LinkEdit/content_edit_btn_link', array(
- 'published' => true,
- 'size' => 12,
- 'url' => $url,
- 'title' => $title,
- 'description' => $description)); ?>
-
-
-
-
-
-
-
-
-
-
- element('content_move_btn', array('size' => '12 col-md-1')); ?>
-
-
-
- element('LinkEdit/content_edit_btn_link', array(
- 'published' => false,
- 'size' => 12,
- 'url' => $url,
- 'title' => $title,
- 'description' => $description)); ?>
-
-
-
-
-
-
-
-
-
-
- element('content_move_btn', array('size' => '12 col-md-1', 'downDisabled' => true)); ?>
-
-
-
- element('LinkEdit/content_edit_btn_link', array(
- 'published' => false,
- 'size' => 12,
- 'url' => $url,
- 'title' => $title,
- 'description' => $description)); ?>
-
-
-
-
-
diff --git a/View/Links/edit_form.ctp b/View/Links/edit_form.ctp
new file mode 100644
index 0000000..d3272d0
--- /dev/null
+++ b/View/Links/edit_form.ctp
@@ -0,0 +1,26 @@
+Form->create(null);
+
+echo $this->Form->input('Link.id', array('type' => 'hidden', value => $linkId));
+
+$fields = array(
+ 'Link.url',
+
+ 'Link.title',
+ 'Link.description',
+ 'Link.link_category_id',
+ 'Link.status'
+);
+foreach($fields as $field){
+ echo $this->Form->input($field, array('type' => 'text'));
+}
+
+echo $this->Form->input('Frame.frame_id', array(
+ 'type' => 'hidden',
+ 'value' => (int)$frameId,
+ )
+);
+
+
+echo $this->Form->end();
\ No newline at end of file
diff --git a/View/Links/index.ctp b/View/Links/index.ctp
index fda2fed..f038f93 100644
--- a/View/Links/index.ctp
+++ b/View/Links/index.ctp
@@ -1,4 +1,4 @@
-Html->script('/links/js/links.js'); ?>
+Html->script('/links/js/links.js?'.time()); ?>
-
+
requestAction('/Links/LinkEdit/view/' . $frameId, array('return')); ?>
+
+ ng-show="visibleAddLinkForm" ng-controller="Links.manage.links.edit">
requestAction('/Links/LinkEdit/viewEdit/' . $frameId, array('return')); ?>
+
requestAction('/Links/LinkCategory/view/' . $frameId, array('return')); ?>
diff --git a/webroot/js/links.js b/webroot/js/links.js
index 5f606ba..aa628d9 100644
--- a/webroot/js/links.js
+++ b/webroot/js/links.js
@@ -1,8 +1,8 @@
/*
-* 発生箇所 : プレビューを閉じる。
-* 編集 閉じる 編集 --- で発生。
-*
-* */
+ * 発生箇所 : プレビューを閉じる。
+ * 編集 閉じる 編集 --- で発生。
+ *
+ * */
//NetCommonsApp.filter('Links_statusView', function() {
//
@@ -24,8 +24,42 @@
// }
// }
//});
+//NetCommonsApp.config(['$resourceProvider', function($resourceProvider) {
+// // Don't strip trailing slashes from calculated URLs
+//// $resourceProvider.defaults.stripTrailingSlashes = false;
+//}]);
+//NetCommonsApp.factory('Links_LinkCategoryRepository', ['$http', function($http){
+// var list = function(frameId){
+//
+// resultPointer = [];
+// // カテゴリをjsonで返す
+// $http.get('/links/link_category/get_categories/' + frameId + '/'+ Math.random() + '.json')
+// .success(function(data){
+// // 3.データ取得できたら、元のObjectに内容を追加
+// angular.extend(resultPointer, data.resultPointer);
+// $scope.$digest();
+// return data.linkCategories;
+// }).error(function(data,status){
+// });
+// return resultPointer;
+// }
+//
+// var loadCategories = function (frameId, loadTarget){
+// $http.get('/links/link_category/get_categories/' + frameId + '/'+ Math.random() + '.json')
+// .success(function(data){
+// // 3.データ取得できたら、元のObjectに内容を追加
+// loadTarget = data.linkCategories;
+// console.log(loadTarget);
+// }).error(function(data,status){
+// });
+// }
+// return {
+// list: list,
+// loadCategories: loadCategories
+// }
+//}]);
-NetCommonsApp.factory('Links_ajaxPostService', ['$http','$q', function($http, $q){
+NetCommonsApp.factory('Links_ajaxPostService', ['$http', '$q', function ($http, $q) {
// ここのスコープは1度しか実行されない
// var success = function (){
//
@@ -33,7 +67,7 @@ NetCommonsApp.factory('Links_ajaxPostService', ['$http','$q', function($http, $q
// var error = function (){
//
// }
- var send = function(postData, formUrl, postUrl){
+ var send = function (postData, formUrl, postUrl) {
var deferred = $q.defer();
var promise = deferred.promise;
@@ -41,8 +75,8 @@ NetCommonsApp.factory('Links_ajaxPostService', ['$http','$q', function($http, $q
// jsonで返さないんだから、.jsonつけなきゃいい?
$http.get(formUrl +
// '/' + Math.random() + '.json')
- '/' + Math.random() )//今はjson形式でないので.jsonつけるのやめた
- .success(function(data) {
+ '/' + Math.random())//今はjson形式でないので.jsonつけるのやめた
+ .success(function (data) {
//フォームエレメント生成
var form = $('
').html(data);
@@ -58,7 +92,7 @@ NetCommonsApp.factory('Links_ajaxPostService', ['$http','$q', function($http, $q
postData._Token.unlocked =
$(form).find('input[name="data[_Token][unlocked]"]').val();
- var postParams= {
+ var postParams = {
_method: 'POST',
data: postData
};
@@ -70,33 +104,33 @@ NetCommonsApp.factory('Links_ajaxPostService', ['$http','$q', function($http, $q
'/' + Math.random() + '.json',
$.param(postParams),
{headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
- .success(function(data) {
+ .success(function (data) {
// success condition
deferred.resolve(data);
//
// $scope.flash.success(data.name);
// $modalInstance.close(); //
})
- .error(function(data, status) {
+ .error(function (data, status) {
// error condition
- deferred.reject(data,status);
+ deferred.reject(data, status);
// $scope.flash.danger(status + ' ' + data.name);
// $scope.sending = false;
});
})
- .error(function(data, status) {
+ .error(function (data, status) {
//keyの取得に失敗
// error condition
- deferred.reject(data,status);
+ deferred.reject(data, status);
// $scope.flash.danger(status + ' ' + data.name);
// $scope.sending = false;
});
- promise.success = function(fn) {
+ promise.success = function (fn) {
promise.then(fn);
return promise;
}
- promise.error = function(fn) {
+ promise.error = function (fn) {
promise.then(null, fn);
return promise;
}
@@ -113,204 +147,230 @@ NetCommonsApp.factory('Links_ajaxPostService', ['$http','$q', function($http, $q
NetCommonsApp.controller('Links',
- function($scope , $http, $sce, $timeout, dialogs, $modal) {
+ function ($scope, $http, $sce, $timeout, dialogs, $modal) {
- $scope.LINK_ADD_URL = '/Links/Links/linkAdd/';
- $scope.PLUGIN_MANAGE_URL = '/Links/Links/manage/';
+ $scope.LINK_ADD_URL = '/Links/Links/linkAdd/';
+ $scope.PLUGIN_MANAGE_URL = '/Links/Links/manage/';
- $scope.frameId = 0;
+ $scope.frameId = 0;
- $scope.visibleHeaderBtn = true;
- $scope.visibleContainer = true;
- $scope.visibleManage = false;
- $scope.visibleAddLink = true;
+ $scope.visibleHeaderBtn = true;
+ $scope.visibleContainer = true;
+ $scope.visibleManage = false;
+ $scope.visibleAddLink = true;
- $scope.visibleContentList = false;
- $scope.visibleContentDropdown = true;
+ $scope.visibleContentList = false;
+ $scope.visibleContentDropdown = true;
- $scope.visibleAddLinkForm = false;
- $scope.Form = {
- 'link_url': '',
- 'title': '',
- 'description': ''
- };
+ $scope.visibleAddLinkForm = false;
+ $scope.Form = {
+ 'link_url': '',
+ 'title': '',
+ 'description': ''
+ };
- $scope.initialize = function(frameId, visibleContentList, visibleContentDropdown) {
- $scope.frameId = frameId;
- $scope.visibleContentList = visibleContentList;
- $scope.visibleContentDropdown = visibleContentDropdown;
+ $scope.initialize = function (frameId, visibleContentList, visibleContentDropdown) {
+ $scope.frameId = frameId;
+ $scope.visibleContentList = visibleContentList;
+ $scope.visibleContentDropdown = visibleContentDropdown;
- };
+ };
- $scope.showContainer = function() {
- $scope.visibleHeaderBtn = true;
- $scope.visibleContainer = true;
- $scope.visibleManage = false;
- $scope.visibleAddLink = true;
- };
-
- $scope.postDisplayStyle = function() {
- if ($scope.visibleContentList === true) {
- $scope.visibleContentList = false;
- $scope.visibleContentDropdown = true;
- } else {
- $scope.visibleContentList = true;
- $scope.visibleContentDropdown = false;
+ $scope.showContainer = function () {
+ $scope.visibleHeaderBtn = true;
+ $scope.visibleContainer = true;
+ $scope.visibleManage = false;
+ $scope.visibleAddLink = true;
+ };
+
+ $scope.postDisplayStyle = function () {
+ if ($scope.visibleContentList === true) {
+ $scope.visibleContentList = false;
+ $scope.visibleContentDropdown = true;
+ } else {
+ $scope.visibleContentList = true;
+ $scope.visibleContentDropdown = false;
+ }
+ $scope.showContainer();
+ };
+
+ $scope.showAddLink = function () {
+ $scope.Form.link_url = '';
+ $scope.Form.title = '';
+ $scope.Form.description = '';
+
+ //リンク追加ダイアログ取得のURL
+ var url = $scope.LINK_ADD_URL + $scope.frameId;
+ //ダイアログで使用するJSコントローラ
+ var controller = 'Links.linkAdd';
+
+ $modal.open({
+ templateUrl: url,
+ controller: controller,
+ backdrop: 'static',
+ scope: $scope
+ });
+ };
+
+ $scope.showManage = function () {
+ $scope.visibleAddLinkForm = false;
+
+ //管理モーダル取得のURL
+ var url = $scope.PLUGIN_MANAGE_URL + $scope.frameId;
+ //ダイアログで使用するJSコントローラ
+ var controller = 'Links.manage';
+
+ modal = $modal.open({
+ templateUrl: url,
+ controller: controller,
+ backdrop: 'static',
+ scope: $scope
+ });
+ modal.result.then(
+ function (result) {
+ // 表示方法変更設定時
+ $scope.postDisplayStyle();
+ },
+ function (reason) {
+ }
+ );
}
- $scope.showContainer();
- };
-
- $scope.showAddLink = function() {
- $scope.Form.link_url = '';
- $scope.Form.title = '';
- $scope.Form.description = '';
-
- //リンク追加ダイアログ取得のURL
- var url = $scope.LINK_ADD_URL + $scope.frameId;
- //ダイアログで使用するJSコントローラ
- var controller = 'Links.linkAdd';
-
- $modal.open({
- templateUrl: url,
- controller: controller,
- backdrop: 'static',
- scope: $scope
- });
- };
-
- $scope.showManage = function(){
- $scope.visibleAddLinkForm = false;
- //管理モーダル取得のURL
- var url = $scope.PLUGIN_MANAGE_URL + $scope.frameId;
- //ダイアログで使用するJSコントローラ
- var controller = 'Links.edit';
-
- modal = $modal.open({
- templateUrl: url,
- controller: controller,
- backdrop: 'static',
- scope: $scope
- });
- modal.result.then(
- function(result) {
- // 表示方法変更設定時
- $scope.postDisplayStyle();
- },
- function(reason) {}
- );
- }
+ // リンク追加・編集時のカテゴリ選択ドロップダウン用モデルにカテゴリ一覧をロードする
+ $scope.loadCategories = function () {
+ $http.get('/links/link_category/get_categories/' + $scope.frameId + '/' + Math.random() + '.json')
+ .success(function (data) {
+ $scope.linkCategories = data.linkCategories;
+ }).error(function (data, status) {
+ $scope.flash.danger(status + ' ' + data.name);
+ });
+
+ }
+ // リンク追加・編集時のカテゴリ選択ドロップダウン用モデル
+ $scope.linkCategories = [''];
});
NetCommonsApp.controller('Links.linkAdd',
- function($scope, $http, $sce, $modalInstance, $timeout, dialogs, Links_ajaxPostService) {
+ function ($scope, $http, $sce, $modalInstance, $timeout, dialogs, Links_ajaxPostService) {
// カテゴリ一覧
- $scope.linkCategories = [];
$scope.newLink = { // postされるデータ
Link: {
- link_category_id:0,
- status: 0, // MyTodo Statusサービスがいるかな
+ link_category_id: 0,
+ status: 0, // MyTodo Statusサービスがいるかな
url: '',
title: '',
- description:''
+ description: ''
},
- Frame:{
- frame_id : $scope.frameId
+ Frame: {
+ frame_id: $scope.frameId
}
}
+ $scope.loadCategories();
+// console.log($scope.linkCategories);
// カテゴリ一覧取得
- $http.get('/links/link_category/get_categories/'+$scope.frameId +'/'+ Math.random() + '.json')
- .success(function(data){
- $scope.linkCategories = data.linkCategories;
-console.log($scope.linkCategories);
- }).error(function(data,status){
- $scope.flash.danger(status + ' ' + data.name);
- });
+// $http.get('/links/link_category/get_categories/'+$scope.frameId +'/'+ Math.random() + '.json')
+// .success(function(data){
+// $scope.linkCategories = data.linkCategories;
+// }).error(function(data,status){
+// $scope.flash.danger(status + ' ' + data.name);
+// });
+
+
+ $scope.cancel = function () {
+ $modalInstance.dismiss('cancel');
+ };
+ $scope.send = function (status) {
+ $scope.newLink.Link.status = status; // MyTodo 権限によって指定できないステータスがあるが、どうガードする?ここでは放置しておいてPHP側かな
+
+ Links_ajaxPostService.send(
+ $scope.newLink,
+ '/links/links/add_form/' + $scope.frameId,
+ '/links/links/add/' + $scope.frameId
+ )
+ .success(function (data) {
+ console.log(data);
+ $scope.flash.success(data.name);
+ $modalInstance.close();
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ console.log(data);
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
- $scope.cancel = function(){
- $modalInstance.dismiss('cancel');
- };
-
- $scope.send = function(status){
- $scope.newLink.Link.status = status; // MyTodo 権限によって指定できないステータスがあるが、どうガードする?ここでは放置しておいてPHP側かな
-
- Links_ajaxPostService.send(
- $scope.newLink,
- '/links/links/add_form/' + $scope.frameId,
- '/links/links/add/' + $scope.frameId
- )
- .success(function(data){
-console.log(data);
- $scope.flash.success(data.name);
- $modalInstance.close();
- })
- .error(function(data, status) {
- //keyの取得に失敗
- console.log(data);
- $scope.flash.danger(status + ' ' + data.name);
- $scope.sending = false;
- });
-
- }
+ }
});
-NetCommonsApp.controller('Links.links.edit',
- function($scope, $http, $sce, $timeout, dialogs, Links_ajaxPostService) {
+// 管理画面リンク編集タブ
+NetCommonsApp.controller('Links.manage.links',
+ function ($scope, $http, $sce, $timeout, dialogs, Links_ajaxPostService) {
$scope.linkCategories = [];
- $scope.init = function(){
+ $scope.init = function () {
// リンクリストを取得して$scope.linkCategoriesにセットする
$http.get('/links/links/all/' +
$scope.frameId + '/' + Math.random() + '.json')
- .success(function(data) {
+ .success(function (data) {
$scope.linkCategories = data;
})
- .error(function(data, status) {
+ .error(function (data, status) {
//取得に失敗 MyTodoエラーメッセージ
$scope.flash.danger(status + ' ' + data.name);
$scope.sending = false;
});
}
+ $scope.showEditLink = function (link) {
+ $scope.visibleAddLinkForm = true;
+ $scope.newLink = link;
+ $scope.loadCategories();
+
+// $scope.Form.link_url = link_url;
+// $scope.Form.title = title;
+// $scope.Form.description = description;
+ };
+
- $scope.deleteButton = function(linkId) {
- dlg = dialogs.confirm('Confirmation','リンクを削除してもよろしいですか?');
+ $scope.deleteButton = function (linkId) {
+ dlg = dialogs.confirm('Confirmation', 'リンクを削除してもよろしいですか?');
dlg.result.then(
- function(btn){
+ function (btn) {
// Yes
$scope.sendDelete(linkId);
},
- function(btn){} // NO
+ function (btn) {
+ } // NO
);
};
- $scope.sendDelete = function(linkId){
+ $scope.sendDelete = function (linkId) {
var sendData = {
- Link:{
+ Link: {
id: linkId
},
- Frame:{
+ Frame: {
frame_id: $scope.frameId
}
};
Links_ajaxPostService.send(
sendData,
- '/links/links/delete_form/' + $scope.frameId + '/' +linkId,
+ '/links/links/delete_form/' + $scope.frameId + '/' + linkId,
'/links/links/delete/' + $scope.frameId
)
- .success(function(data){
+ .success(function (data) {
console.log(data);
$scope.flash.success(data.name);
$modalInstance.close();
})
- .error(function(data, status) {
+ .error(function (data, status) {
//keyの取得に失敗
console.log(data);
$scope.flash.danger(status + ' ' + data.name);
@@ -319,25 +379,27 @@ NetCommonsApp.controller('Links.links.edit',
}
- $scope.send = function(){
- Links_ajaxPostService.send(
- $scope.linkCategories,
- '/links/links/update_weight_form/' + $scope.frameId + '/' + Math.random(),
- '/links/links/update_weight/' + $scope.frameId + '/' + Math.random() + '.json'
- )
- .success(function(data){
- console.log(data);
- $scope.flash.success(data.name);
- $modalInstance.close();
- })
- .error(function(data, status) {
- //keyの取得に失敗
- console.log(data);
- $scope.flash.danger(status + ' ' + data.name);
- $scope.sending = false;
- });
- }
+
+// $scope.send = function () {
+// Links_ajaxPostService.send(
+// $scope.linkCategories,
+// '/links/links/update_weight_form/' + $scope.frameId + '/' + Math.random(),
+// '/links/links/update_weight/' + $scope.frameId + '/' + Math.random() + '.json'
+// )
+// .success(function (data) {
+// console.log(data);
+// $scope.flash.success(data.name);
+// $modalInstance.close();
+// })
+// .error(function (data, status) {
+// //keyの取得に失敗
+// console.log(data);
+// $scope.flash.danger(status + ' ' + data.name);
+// $scope.sending = false;
+// });
+//
+// }
var move = function (categoryIndex, origin, destination) {
console.log($scope.linkCategories[categoryIndex]);
@@ -348,16 +410,14 @@ NetCommonsApp.controller('Links.links.edit',
var tempWeight = $scope.linkCategories[categoryIndex].links[destination].LinkOrder.weight;
$scope.linkCategories[categoryIndex].links[destination].LinkOrder.weight = $scope.linkCategories[categoryIndex].links[origin].LinkOrder.weight;
$scope.linkCategories[categoryIndex].links[origin].LinkOrder.weight = tempWeight;
-
- $scope.send();
};
- $scope.moveUp = function(categoryIndex, linkIndex){
+ $scope.moveUp = function (categoryIndex, linkIndex) {
move(categoryIndex, linkIndex, linkIndex - 1);
};
- $scope.moveDown = function(categoryIndex, linkIndex){
+ $scope.moveDown = function (categoryIndex, linkIndex) {
move(categoryIndex, linkIndex, linkIndex + 1);
};
@@ -367,10 +427,50 @@ NetCommonsApp.controller('Links.links.edit',
// }
}
)
+NetCommonsApp.controller('Links.manage.links.edit',
+ function ($scope, $http, $sce, $timeout, dialogs, Links_ajaxPostService) {
+ // リンク編集フォームより
+ $scope.send = function (status) {
+ console.log($scope.newLink);
+ $scope.newLink.Link.status = status; // MyTodo 権限によって指定できないステータスがあるが、どうガードする?ここでは放置しておいてPHP側かな
+
+ // 余計なフィールドデータをPOSTするとセキュリティコンポーネントにBlackHole送りにされるので必用なフィールドだけ抜き出す。
+ var data = {
+ Link:{
+ id: $scope.newLink.Link.id,
+ url:$scope.newLink.Link.url,
+ link_category_id:$scope.newLink.Link.link_category_id,
+ title:$scope.newLink.Link.title,
+ description:$scope.newLink.Link.description,
+ status: $scope.newLink.Link.status
+ },
+ Frame: {
+ frame_id: $scope.frameId
+ }
+ }
+
+ Links_ajaxPostService.send(
+ data,
+ '/links/links/edit_form/' + $scope.frameId + '/' + $scope.newLink.Link.id,
+ '/links/links/edit/' + $scope.frameId + '/' + $scope.newLink.Link.id
+ )
+ .success(function (data) {
+ console.log(data);
+ $scope.flash.success(data.name);
+ $modalInstance.close();
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ console.log(data);
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+ }
+ });
-NetCommonsApp.controller('Links.edit',
- function($scope, $http, $sce, $modalInstance, $timeout, dialogs, Links_ajaxPostService) {
+NetCommonsApp.controller('Links.manage',
+ function ($scope, $http, $sce, $modalInstance, $timeout, dialogs, Links_ajaxPostService) {
/**
@@ -407,12 +507,12 @@ NetCommonsApp.controller('Links.edit',
}
};
- $scope.editCategories= {
+ $scope.editCategories = {
_method: 'POST'
};
$scope.editCategories.data = {
- LinkCategories:[],
+ LinkCategories: [],
// LinkCategory:[],
// LinkCategoryOrder:[],
Frame: {
@@ -426,18 +526,18 @@ NetCommonsApp.controller('Links.edit',
};
- $scope.initialize = function(frameId, linkCategories) {
+ $scope.initialize = function (frameId, linkCategories) {
$scope.frameId = frameId;
- angular.forEach(linkCategories, function(oneRecord){
+ angular.forEach(linkCategories, function (oneRecord) {
$scope.editCategories.data.LinkCategories.push(
{
LinkCategory: {
id: oneRecord.LinkCategory.id,
name: oneRecord.LinkCategory.name
},
- LinkCategoryOrder:{
- id:oneRecord.LinkCategoryOrder.id,
- weight:oneRecord.LinkCategoryOrder.weight
+ LinkCategoryOrder: {
+ id: oneRecord.LinkCategoryOrder.id,
+ weight: oneRecord.LinkCategoryOrder.weight
}
}
@@ -461,64 +561,58 @@ NetCommonsApp.controller('Links.edit',
};
+ $scope.cancel = function () {
+ $modalInstance.dismiss('cancel');
+ };
- $scope.cancel = function(){
- $modalInstance.dismiss('cancel');
- };
+ $scope.postDisplayStyle = function () {
+ $modalInstance.close();
+ };
- $scope.postDisplayStyle = function(){
- $modalInstance.close();
- };
- $scope.showEditLink = function(link_url, title, description) {
- $scope.visibleAddLinkForm = true;
- $scope.Form.link_url = link_url;
- $scope.Form.title = title;
- $scope.Form.description = description;
- };
+ $scope.closeEditLink = function () {
+ $scope.visibleAddLinkForm = false;
+ $scope.Form.link_url = '';
+ $scope.Form.title = '';
+ $scope.Form.description = '';
+ };
- $scope.closeEditLink = function() {
- $scope.visibleAddLinkForm = false;
- $scope.Form.link_url = '';
- $scope.Form.title = '';
- $scope.Form.description = '';
- };
-
-
- $scope.deleteEditCategory = function(index) {
-
- dlg = dialogs.confirm('Confirmation','カテゴリーを削除してもよろしいですか?');
- dlg.result.then(
- function(btn){
- var postData = {
- LinkCategory:{
- id: $scope.editCategories.data.LinkCategories[index].LinkCategory.id
- },
- Frame: {
- frame_id: $scope.frameId
- }
- };
- var formUrl = '/links/link_category/delete_form/'+$scope.frameId;
- var postUrl = '/links/link_category/delete/'+$scope.frameId;
- var callback = function(){};
- Links_ajaxPostService.send(postData, formUrl, postUrl)
- .success(function(data){
- $scope.flash.success(data.name);
- $modalInstance.close();
- })
- .error(function(data, status) {
- //keyの取得に失敗
- $scope.flash.danger(status + ' ' + data.name);
- $scope.sending = false;
- });
- //削除フォーム取得
- // セキュリティキーセット
- // ポスト
- }, // Yes
- function(btn){} // NO
- );
- };
+ $scope.deleteEditCategory = function (index) {
+
+ dlg = dialogs.confirm('Confirmation', 'カテゴリーを削除してもよろしいですか?');
+ dlg.result.then(
+ function (btn) {
+ var postData = {
+ LinkCategory: {
+ id: $scope.editCategories.data.LinkCategories[index].LinkCategory.id
+ },
+ Frame: {
+ frame_id: $scope.frameId
+ }
+ };
+ var formUrl = '/links/link_category/delete_form/' + $scope.frameId;
+ var postUrl = '/links/link_category/delete/' + $scope.frameId;
+ var callback = function () {
+ };
+ Links_ajaxPostService.send(postData, formUrl, postUrl)
+ .success(function (data) {
+ $scope.flash.success(data.name);
+ $modalInstance.close();
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+ //削除フォーム取得
+ // セキュリティキーセット
+ // ポスト
+ }, // Yes
+ function (btn) {
+ } // NO
+ );
+ };
/**
@@ -526,12 +620,12 @@ NetCommonsApp.controller('Links.edit',
*
* @return {void}
*/
- $scope.addCategory = function() {
+ $scope.addCategory = function () {
$scope.sending = true;
$http.get('/links/link_category/form/' +
$scope.frameId + '/' + Math.random() + '.json')
- .success(function(data) {
+ .success(function (data) {
//フォームエレメント生成
var form = $('
').html(data);
@@ -547,7 +641,7 @@ NetCommonsApp.controller('Links.edit',
//登録情報をPOST
$scope.sendCategoryPost($scope.edit);
})
- .error(function(data, status) {
+ .error(function (data, status) {
//keyの取得に失敗
$scope.flash.danger(status + ' ' + data.name);
$scope.sending = false;
@@ -560,7 +654,7 @@ NetCommonsApp.controller('Links.edit',
* @param {Object.
} postParams
* @return {void}
*/
- $scope.sendCategoryPost = function(postParams) {
+ $scope.sendCategoryPost = function (postParams) {
//$http.post($scope.PLUGIN_EDIT_URL + Math.random() + '.json',
$http.post('/links/link_category/add/' +
$scope.frameId + '/' + Math.random() + '.json',
@@ -569,12 +663,12 @@ NetCommonsApp.controller('Links.edit',
//postParams)
$.param(postParams),
{headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
- .success(function(data) {
+ .success(function (data) {
$scope.flash.success(data.name);
// MyTodo カテゴリ追加し終わったらカテゴリ一覧をリロードしたいよなぁ
// $modalInstance.close(data.announcement);
})
- .error(function(data, status) {
+ .error(function (data, status) {
$scope.flash.danger(status + ' ' + data.name);
$scope.sending = false;
});
@@ -584,12 +678,12 @@ NetCommonsApp.controller('Links.edit',
*
* @return {void}
*/
- $scope.updateCategories = function() {
+ $scope.updateCategories = function () {
$scope.sending = true;
$http.get('/links/link_category/categories_form/' +
$scope.frameId + '/' + Math.random() + '.json')
- .success(function(data) {
+ .success(function (data) {
//フォームエレメント生成
var form = $('').html(data);
@@ -606,7 +700,7 @@ NetCommonsApp.controller('Links.edit',
//登録情報をPOST
$scope.sendCategoriesPost($scope.editCategories);
})
- .error(function(data, status) {
+ .error(function (data, status) {
//keyの取得に失敗
$scope.flash.danger(status + ' ' + data.name);
$scope.sending = false;
@@ -619,10 +713,10 @@ NetCommonsApp.controller('Links.edit',
* @param {Object.
} postParams
* @return {void}
*/
- $scope.sendCategoriesPost = function(postParams) {
+ $scope.sendCategoriesPost = function (postParams) {
//$http.post($scope.PLUGIN_EDIT_URL + Math.random() + '.json',
postParams = angular.fromJson(angular.toJson(postParams)); // hashに$$hashKeyがつくのでこれで除去してる
-console.log(postParams);
+ console.log(postParams);
$http.post('/links/link_category/update_all/' +
$scope.frameId + '/' + Math.random() + '.json',
//$.param(postParams))
@@ -630,11 +724,11 @@ console.log(postParams);
//postParams)
$.param(postParams),
{headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
- .success(function(data) {
+ .success(function (data) {
$scope.flash.success(data.name);
$modalInstance.close(); //
})
- .error(function(data, status) {
+ .error(function (data, status) {
$scope.flash.danger(status + ' ' + data.name);
$scope.sending = false;
});
@@ -651,11 +745,11 @@ console.log(postParams);
};
- $scope.moveUp = function(index){
+ $scope.moveUp = function (index) {
move(index, index - 1);
};
- $scope.moveDown = function(index){
+ $scope.moveDown = function (index) {
move(index, index + 1);
};
From bb26a1862e505510fe301d82d0fdebdb5668cc4b Mon Sep 17 00:00:00 2001
From: RyujiAMANO
Date: Wed, 19 Nov 2014 09:49:13 +0900
Subject: [PATCH 49/53] =?UTF-8?q?=E3=83=95=E3=83=AC=E3=83=BC=E3=83=A0?=
=?UTF-8?q?=E8=A8=AD=E5=AE=9A=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Controller/LinkFrameSettingController.php | 117 ++++++++++
Model/LinkFrameSetting.php | 32 +++
View/LinkDisplay/view.ctp | 27 ++-
View/LinkFrameSetting/form.ctp | 20 ++
View/Links/manage.ctp | 4 +-
webroot/js/links.js | 254 ++++++++++++++++++----
6 files changed, 404 insertions(+), 50 deletions(-)
create mode 100644 Controller/LinkFrameSettingController.php
create mode 100644 View/LinkFrameSetting/form.ctp
diff --git a/Controller/LinkFrameSettingController.php b/Controller/LinkFrameSettingController.php
new file mode 100644
index 0000000..7b4bcd1
--- /dev/null
+++ b/Controller/LinkFrameSettingController.php
@@ -0,0 +1,117 @@
+
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppController', 'Links.Controller');
+
+/**
+ * Links Controller
+ *
+ * @author Ryuji AMANO
+ * @package NetCommons\Links\Controller
+ *
+ * @property LinkFrameSetting $LinkFrameSetting
+ */
+class LinkFrameSettingController extends LinksAppController {
+
+public $helpers = array('Links.LinksStatus');
+/**
+ * use model
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Links.LinkFrameSetting',
+ );
+
+/**
+ * use component
+ *
+ * @var array
+ */
+
+ public $components = array(
+ 'NetCommons.NetCommonsBlock', //use Announcement model
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsRoomRole',
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+ $this->Auth->allow();
+
+ $frameId = (isset($this->params['pass'][0]) ? (int)$this->params['pass'][0] : 0);
+ //Frameのデータをviewにセット
+ if (! $this->NetCommonsFrame->setView($this, $frameId)) {
+ $this->response->statusCode(400);
+ return;
+ }
+ //Roleのデータをviewにセット
+ if (! $this->NetCommonsRoomRole->setView($this)) {
+ $this->response->statusCode(400);
+ return;
+ }
+ }
+
+ public function get($frameId = 0) {
+ $linkFrameSetting = $this->LinkFrameSetting->getByFrameId($frameId);
+ $this->set('linkFrameSetting', $linkFrameSetting['LinkFrameSetting']);
+ $this->set('_serialize', 'linkFrameSetting');
+ return $this->render(false);
+
+ }
+
+
+ public function form($frameId = 0) {
+ $this->set(compact('frameId'));
+ $linkFrameSetting = $this->LinkFrameSetting->getByFrameId($frameId);
+ $this->set(compact('linkFrameSetting'));
+ }
+
+ public function edit($frameId) {
+ if (! $this->request->isPost()) {
+ throw new MethodNotAllowedException();
+ }
+ //保存
+ if ($this->LinkFrameSetting->save($this->data)) {
+
+ $result = array(
+ 'name' => __d('net_commons', 'Successfully finished.'),
+ 'link' => $this->data,
+ );
+
+ $this->set(compact('result'));
+ $this->set('_serialize', 'result');
+ return $this->render(false);
+ } else {
+
+ $error = __d('net_commons', 'Failed to register data.');
+ $error .= $this->formatValidationErrors($this->LinkFrameSetting->validationErrors);
+ throw new ForbiddenException($error);
+ }
+
+ }
+
+ // MyTodo モデルに移動するか、ヘルパかコンポーネントかビヘイビアにする…
+ protected function formatValidationErrors($validationErrors) {
+ $errors = array();
+ foreach($validationErrors as $field => $fieldErrors){
+ foreach($fieldErrors as $errorMessage){
+ $errors[] = __d('links', $field) . ':' . __d('links', $errorMessage);
+ }
+ }
+ $returnMessage = implode("\n", $errors);
+ return $returnMessage;
+ }
+}
diff --git a/Model/LinkFrameSetting.php b/Model/LinkFrameSetting.php
index 19c288d..c2edab7 100644
--- a/Model/LinkFrameSetting.php
+++ b/Model/LinkFrameSetting.php
@@ -62,4 +62,36 @@ class LinkFrameSetting extends LinksAppModel {
),
),
);
+
+ public function getByFrameId($frameId) {
+ $this->Frame = ClassRegistry::init('Frames.Frame');
+ $frame = $this->Frame->findById($frameId);
+ $frameKey = $frame['Frame']['key'];
+ $linkFrameSetting = $this->findByFrameKey($frameKey);
+
+ if($linkFrameSetting){
+ return $linkFrameSetting;
+ }else{
+ $newLinkFrameSetting = $this->getBlank();
+ $newLinkFrameSetting['LinkFrameSetting']['frame_key'] = $frameKey;
+ return $newLinkFrameSetting;
+ }
+ }
+
+ private function getBlank() {
+ $defaults = array();
+
+ $schema = (array)$this->schema();
+ foreach ($schema as $field => $properties) {
+ if ($this->primaryKey !== $field && isset($properties['default']) && $properties['default'] !== '') {
+ $defaults[$field] = $properties['default'];
+ }else{
+ $defaults[$field] = null;
+ }
+ }
+ $ret = array(
+ $this->alias => $defaults
+ );
+ return $ret;
+ }
}
diff --git a/View/LinkDisplay/view.ctp b/View/LinkDisplay/view.ctp
index 2675c63..41d1cc0 100644
--- a/View/LinkDisplay/view.ctp
+++ b/View/LinkDisplay/view.ctp
@@ -1,6 +1,7 @@