From ce7656674c9a6f1a9f44573cb73ebcd48ded39be Mon Sep 17 00:00:00 2001 From: bfederle Date: Mon, 6 Feb 2012 12:32:39 -0800 Subject: [PATCH] Add project detail view --- ui/scripts/projects.js | 82 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 14 deletions(-) diff --git a/ui/scripts/projects.js b/ui/scripts/projects.js index 5c83fbe4a73..adb40b51c96 100644 --- a/ui/scripts/projects.js +++ b/ui/scripts/projects.js @@ -526,20 +526,20 @@ state: { label: 'Status', indicator: { 'Active': 'on', 'Destroyed': 'off', 'Disabled': 'off', 'Left Project': 'off' } } }, - dataProvider: function(args) { - var array1 = []; - if(args.filterBy != null) { - if(args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) { - switch(args.filterBy.search.by) { - case "name": - if(args.filterBy.search.value.length > 0) - array1.push("&keyword=" + args.filterBy.search.value); - break; - } - } - } - - var apiCmd = "listProjects&page=" + args.page + "&pagesize=" + pageSize + array1.join("") + '&listAll=true'; + dataProvider: function(args) { + var array1 = []; + if(args.filterBy != null) { + if(args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) { + switch(args.filterBy.search.by) { + case "name": + if(args.filterBy.search.value.length > 0) + array1.push("&keyword=" + args.filterBy.search.value); + break; + } + } + } + + var apiCmd = "listProjects&page=" + args.page + "&pagesize=" + pageSize + array1.join("") + '&listAll=true'; $.ajax({ url: createURL(apiCmd, { ignoreProject: true }), dataType: 'json', @@ -726,6 +726,60 @@ poll: pollAsyncJobResult } } + }, + + detailView: { + actions: { + edit: { + label: 'Edit', + action: function(args) { + $.ajax({ + url: createURL('updateProject'), + data: $.extend(true, {}, args.context.projects[0], args.data), + success: function(json) { + args.response.success(); + }, + error: function(json) { + args.response.error(parseXMLHttpResponse(json)); + } + }); + }, + messages: { + notification: function(args) { return 'Edited project details'; } + } + } + }, + tabs: { + details: { + title: 'Details', + fields: [ + { + name: { label: 'Name' } + }, + { + displaytext: { label: 'Display text', isEditable: true }, + domain: { label: 'Domain' }, + account: { label: 'Account'}, + state: { label: 'State' } + } + ], + dataProvider: function(args) { + var projectID = args.context.projects[0].id; + + $.ajax({ + url: createURL('listProjects'), + data: { + id: projectID + }, + success: function(json) { + args.response.success({ + data: json.listprojectsresponse.project[0] + }); + } + }); + } + } + } } } },