[Kimchi-devel] [PATCH] Add template clone support
Hongliang Wang
hlwang at linux.vnet.ibm.com
Thu Apr 3 09:05:17 UTC 2014
On 04/03/2014 02:46 PM, Sheldon wrote:
> Cool, Looks good to me.
> Tested-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> Just a minor inline comment below
>
>
> On 04/03/2014 01:56 AM, Adam King wrote:
>> Add support for cloning templates to the clone tab.
>>
>> Signed-off-by: Adam King <rak at linux.vnet.ibm.com>
>> ---
>> ui/js/src/kimchi.api.js | 11 +++++++++++
>> ui/js/src/kimchi.template_main.js | 16 ++++++++++++++--
>> ui/pages/tabs/templates.html.tmpl | 1 +
>> 3 files changed, 26 insertions(+), 2 deletions(-)
>>
>> diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
>> index 0c5c790..376bc86 100644
>> --- a/ui/js/src/kimchi.api.js
>> +++ b/ui/js/src/kimchi.api.js
>> @@ -143,6 +143,17 @@ var kimchi = {
>> });
>> },
>>
>> + cloneTemplate : function(tem, suc, err) {
>> + kimchi.requestJSON({
>> + url : kimchi.url + 'templates/' +
>> encodeURIComponent(tem) + "/clone",
>> + type : 'POST',
>> + contentType : 'application/json',
>> + dataType : 'json',
>> + success : suc,
>> + error : err
>> + });
>> + },
>> +
>> listTemplates : function(suc, err) {
>> kimchi.requestJSON({
>> url : kimchi.url + 'templates',
>> diff --git a/ui/js/src/kimchi.template_main.js
>> b/ui/js/src/kimchi.template_main.js
>> index 5de6e8c..9f19a5c 100644
>> --- a/ui/js/src/kimchi.template_main.js
>> +++ b/ui/js/src/kimchi.template_main.js
>> @@ -25,22 +25,34 @@ kimchi.doListTemplates = function() {
>> listHtml += kimchi.template(templateHtml, value);
>> });
>> $('#templateList').html(listHtml);
>> - kimchi.bindClick();
>> + kimchi.templateBindClick();
>> } else {
>> $('#templateList').html('');
>> $('#noTemplates').show();
>> }
>> + $('html').css('cursor', 'auto');
>> }, function(err) {
>> kimchi.message.error(err.responseJSON.reason);
>> + $('html').css('cursor', 'auto');
>> });
>> };
>>
>> -kimchi.bindClick = function() {
>> +kimchi.templateBindClick = function() {
>> $('.template-edit').on('click', function(event) {
>> var templateName = $(this).data('template');
>> kimchi.selectedTemplate = templateName;
>> kimchi.window.open("template-edit.html");
>> });
>> + $('.template-clone').on('click', function(event) {
>> + kimchi.selectedTemplate = $(this).data('template');
>> + $('html').css('cursor', 'wait');
>> + kimchi.cloneTemplate(kimchi.selectedTemplate , function() {
>> + kimchi.doListTemplates();
>> + }, function(err) {
>> + kimchi.message.error(err.responseJSON.reason);
>> + kimchi.doListTemplates();
>> + });
>> + });
>> $('.template-delete').on('click', function(event) {
>> var $template = $(this);
>> var settings = {
>> diff --git a/ui/pages/tabs/templates.html.tmpl
>> b/ui/pages/tabs/templates.html.tmpl
>> index b6edbaf..6ae6640 100644
>> --- a/ui/pages/tabs/templates.html.tmpl
>> +++ b/ui/pages/tabs/templates.html.tmpl
>> @@ -43,6 +43,7 @@
>> <span class="text">$_("Actions")</span><span
>> class="arrow"></span>
>> <div class="popover actionsheet right-side"
>> style="width: 250px">
>> <a class="button-big template-edit"
>> data-template='{name}'>$_("Edit")</a>
>> + <a class="button-big template-clone"
>> data-template='{name}'>$_("Clone")</a>
> do we need to add "Clone" to i18n.html.tmpl for i18n?
It's already translated here and seems no need to add to i18n.html.
>> <a class="button-big red template-delete"
>> data-template='{name}'>$_("Delete")</a>
>> </div>
>> </div>
>
>
More information about the Kimchi-devel
mailing list