On 01/28/2011 02:32 PM, Adam Young wrote:
On 01/28/2011 02:04 PM, Adam Young wrote:



_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

From 6ed009ff684a3c486ce928a6a74936944b8484ec Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Fri, 28 Jan 2011 13:06:34 -0500
Subject: [PATCH] services list

Declaritive Service definition
Fixed a problem with multiple calls to create breaking the link between the select box and the text box
swapped the select and the text

https://fedorahosted.org/freeipa/ticket/442
---
 install/ui/entity.js  |    4 +
 install/ui/service.js |  248 ++++++++++++++++---------------------------------
 install/ui/widget.js  |    1 +
 3 files changed, 86 insertions(+), 167 deletions(-)

diff --git a/install/ui/entity.js b/install/ui/entity.js
index 69dd444f83c9ae32a88f8ae53b0995f1033627a0..ec4a2adc1baf23e5355c8ae2fe4f2a24ee750b0d 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -111,6 +111,10 @@ IPA.entity = function (spec) {
     };
 
     that.add_dialog = function(dialog) {
+        return that.dialog(dialog);
+    }
+
+    that.dialog = function(dialog) {
         dialog.entity_name = that.name;
         that.dialogs.push(dialog);
         that.dialogs_by_name[dialog.name] = dialog;
diff --git a/install/ui/service.js b/install/ui/service.js
index f67d755def899cac912431cc7b468756d31ba310..2352fa42d09c44aec28311150c645ae039f1ce1d 100644
--- a/install/ui/service.js
+++ b/install/ui/service.js
@@ -25,143 +25,88 @@
 
 IPA.entity_factories.service = function () {
 
-    var that = IPA.entity({
+    return  IPA.entity({
         'name': 'service'
-    });
-
-    that.init = function() {
-
-        that.create_association({
+    }).
+        association({
             'name': 'host',
             'add_method': 'add_host',
             'remove_method': 'remove_host'
-        });
-
-        var dialog = IPA.service_add_dialog({
-            'name': 'add',
-            'title': 'Add New Service'
-        });
-        that.add_dialog(dialog);
-
-        var facet = IPA.service_search_facet({
-            'name': 'search',
-            'label': 'Search'
-        });
-        that.add_facet(facet);
-
-        facet = IPA.service_details_facet({
-            'name': 'details'
-        });
-        that.add_facet(facet);
-
-        facet = IPA.service_managedby_host_facet({
+        }).
+        dialog(
+            IPA.service_add_dialog({
+                'name': 'add',
+                'title': 'Add New Service'
+            })).
+        facet( IPA.search_facet().
+               column({name:'krbprincipalname'})).
+        facet( IPA.service_details_facet()).
+        facet( IPA.service_managedby_host_facet({
             'name': 'managedby_host',
-            'label': IPA.messages.association.managedby+' '+IPA.metadata['host'].label,
+            'label': IPA.messages.association.managedby
+                +' '+IPA.metadata['host'].label,
             'other_entity': 'host'
-        });
-        that.add_facet(facet);
-
-        that.entity_init();
-    };
-
-    return that;
+        }));
 };
 
 
+IPA.service_select_widget = function (spec){
+
+    var that = IPA.text_widget(spec);
+    var known_services = ["", "cifs", "DNS", "ftp", "HTTP","imap", "ldap",
+                          "libvirt","nfs","qpidd","smtp"];
+
+    that.parent_create = that.create;
+
+    that.create = function(container) {
+
+        var select_widget = $('<select/>');
+        for (var i = 0; i < known_services.length; i += 1){
+            select_widget.append($('<option/>',{
+                text: known_services[i],
+                click: function(){
+                    that.input.val(this.value);
+                }
+            }));
+        }
+        container.append(select_widget);
+        that.parent_create(container);
+    }
+
+    return that;
+
+}
+
+
+/*TODO: the following labels etc. all need to be replaced with I18N strings */
+
 IPA.service_add_dialog = function (spec) {
 
     spec = spec || {};
 
-    var that = IPA.add_dialog(spec);
-
-    that.init = function() {
-
-        that.add_field(IPA.widget({
+    var that = IPA.add_dialog(spec).
+        field(IPA.widget({
             name: 'krbprincipalname'
-        }));
-
-        // TODO: Replace with i18n label
-        that.add_field(IPA.text_widget({
+        })).
+        field(IPA.service_select_widget({
             'name': 'service',
             'label': 'Service',
             'size': 20,
             'undo': false
-        }));
-
-        // TODO: Replace with i18n label
-        that.add_field(IPA.text_widget({
+        })).
+        field(IPA.text_widget({
             'name': 'host',
             'label': 'Host Name',
             'size': 40,
             'undo': false
-        }));
-
-        // TODO: Replace with i18n label
-        that.add_field(IPA.checkbox_widget({
+        })).
+        field(IPA.checkbox_widget({
             name: 'force',
             label: 'Force',
             tooltip: 'force principal name even if not in DNS',
             undo: false
         }));
 
-        that.add_dialog_init();
-    };
-
-    that.create = function() {
-
-        var table = $('<table/>').appendTo(that.container);
-
-        var field = that.get_field('service');
-
-        var tr = $('<tr/>').appendTo(table);
-
-        var td = $('<td/>', {
-            style: 'vertical-align: top;',
-            title: field.label
-        }).appendTo(tr);
-        td.append(field.label+': ');
-
-        td = $('<td/>', {
-            'style': 'vertical-align: top;'
-        }).appendTo(tr);
-
-        var span = $('<span/>', { 'name': 'service' }).appendTo(td);
-        field.create(span);
-
-        field = that.get_field('host');
-
-        tr = $('<tr/>').appendTo(table);
-
-        td = $('<td/>', {
-            style: 'vertical-align: top;',
-            title: field.label
-        }).appendTo(tr);
-        td.append(field.label+': ');
-
-        td = $('<td/>', {
-            'style': 'vertical-align: top;'
-        }).appendTo(tr);
-
-        span = $('<span/>', { 'name': 'host' }).appendTo(td);
-        field.create(span);
-
-        field = that.get_field('force');
-
-        tr = $('<tr/>').appendTo(table);
-
-        td = $('<td/>', {
-            style: 'vertical-align: top;',
-            title: field.label
-        }).appendTo(tr);
-        td.append(field.label+': ');
-
-        td = $('<td/>', {
-            'style': 'vertical-align: top;'
-        }).appendTo(tr);
-
-        span = $('<span/>', { 'name': 'force' }).appendTo(td);
-        field.create(span);
-    };
 
     that.save = function(record) {
 
@@ -181,78 +126,47 @@ IPA.service_add_dialog = function (spec) {
 };
 
 
-IPA.service_search_facet = function (spec) {
-
-    spec = spec || {};
-
-    var that = IPA.search_facet(spec);
-
-    that.init = function() {
-
-        that.create_column({name:'krbprincipalname'});
-        that.search_facet_init();
-    };
-
-    return that;
-};
-
-
 IPA.service_details_facet = function (spec) {
 
     spec = spec || {};
 
-    var that = IPA.details_facet(spec);
-
-    that.init = function() {
-
-        var section = IPA.details_list_section({
+    var that = IPA.details_facet(spec).
+        section(IPA.stanza({
             name: 'details',
             label: 'Service Settings'
-        });
-        that.add_section(section);
-
-        section.create_field({
+        }).
+        input({
             name: 'krbprincipalname'
-        });
-
-        // TODO: Replace with i18n label
-        section.create_field({
+        }).
+        input({
             name: 'service',
             label: 'Service',
             load: service_service_load
-        });
-
-        // TODO: Replace with i18n label
-        section.create_field({
+        }).
+        input({
             name: 'host',
             label: 'Host Name',
             load: service_host_load
-        });
+        })).
+        section(
+            IPA.stanza({
+                name: 'provisioning',
+                label: 'Provisioning'
+            }).
+                custom_input(service_provisioning_status_widget({
+                    name: 'provisioning_status',
+                    label: 'Status'
+                }))).
+        section(
+            IPA.stanza({
+                name: 'certificate',
+                label: 'Service Certificate'
+            }).
+                custom_input((service_certificate_status_widget({
+                    name: 'certificate_status',
+                    label: 'Status'
+                }))));
 
-        section = IPA.details_list_section({
-            name: 'provisioning',
-            label: 'Provisioning'
-        });
-        that.add_section(section);
-
-        section.add_field(service_provisioning_status_widget({
-            name: 'provisioning_status',
-            label: 'Status'
-        }));
-
-        section = IPA.details_list_section({
-            name: 'certificate',
-            label: 'Service Certificate'
-        });
-        that.add_section(section);
-
-        section.add_field(service_certificate_status_widget({
-            name: 'certificate_status',
-            label: 'Status'
-        }));
-
-        that.details_facet_init();
-    };
 
     return that;
 };
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 3bb5c0f5a28f70c233ead511247de6c8cbb5ebf6..19dc4d121dbd8faabe9342fefae7cabacfe2f0bf 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -262,6 +262,7 @@ IPA.text_widget = function(spec) {
         undo.click(function() {
             that.reset();
         });
+        that.input = input;
     };
 
     that.load = function(record) {
-- 
1.7.3.5

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to