]> source.dussan.org Git - archiva.git/commitdiff
add some labels
authorOlivier Lamy <olamy@apache.org>
Thu, 13 Dec 2012 15:37:32 +0000 (15:37 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 13 Dec 2012 15:37:32 +0000 (15:37 +0000)
add a modified observer to change save button when something has changed.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1421342 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html

index 55ef253de4a5099e018608b1e6c5ab1128ec6d97..99265dff5ba62a23f691abc65a081b55981daed2 100644 (file)
@@ -593,5 +593,9 @@ redback.runtime.ldap.ssl.label=ssl enabled
 redback.runtime.ldap.authenticationMethod.label=authenticationMethod
 ldap.bind.authenticator.enabled.help.content=Will toggle the use of authenticator that will authenticate using the bind operation.
 ldap.bind.authenticator.allowEmptyPasswords.help.content=Allow to use empty password with Ldap authenticator.
+redback.runtime.properties.key.label=Key
+redback.runtime.properties.value.label=Value
+redback.runtime.user-managers.impls.choosed=UserManager(s) choosed
+redback.runtime.user-managers.impls.available=UserManager(s) availables
 
 
index 470c3f4934f4b1272ed038677102fe576debaae3..1e40be9527b85af82bdf9539587d784ffb36409e 100644 (file)
@@ -1152,52 +1152,84 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
 
 
   ArchivaRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries){
+    var self=this;
+    this.modified=ko.observable(false);
+    this.modified.subscribe(function(newValue){$.log("ArchivaRuntimeConfiguration modified")});
+
     this.userManagerImpls=ko.observableArray(userManagerImpls);
+    this.userManagerImpls.subscribe(function(newValue){self.modified(true)});
+
     this.ldapConfiguration=ko.observable(ldapConfiguration);
+    this.ldapConfiguration.subscribe(function(newValue){self.modified(true)});
+
     this.migratedFromRedbackConfiguration=ko.observable(migratedFromRedbackConfiguration);
+
     this.configurationPropertiesEntries=ko.observableArray(configurationPropertiesEntries?configurationPropertiesEntries:[]);
+    this.configurationPropertiesEntries.subscribe(function(newValue){
+      self.modified(true);
+      $.log("configurationPropertiesEntries modified")
+    });
   }
 
   mapArchivaRuntimeConfiguration=function(data){
+    var archivaRuntimeConfiguration =
+            new ArchivaRuntimeConfiguration(data.userManagerImpls,mapLdapConfiguration(data.ldapConfiguration),data.migratedFromRedbackConfiguration);
+
 
     var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){
-      return new Entry(item.key, item.value);
+      return new Entry(item.key, item.value,function(newValue){
+        archivaRuntimeConfiguration.modified(true);
+      });
     });
     if (!$.isArray(configurationPropertiesEntries)){
-        configurationPropertiesEntries=[];
+      configurationPropertiesEntries=[];
     }
+    archivaRuntimeConfiguration.configurationPropertiesEntries(configurationPropertiesEntries);
+    archivaRuntimeConfiguration.modified(false);
+    return archivaRuntimeConfiguration;
 
-    return new ArchivaRuntimeConfiguration(data.userManagerImpls,mapLdapConfiguration(data.ldapConfiguration),data.migratedFromRedbackConfiguration,
-                                           configurationPropertiesEntries);
   }
 
   LdapConfiguration=function(hostName,port,ssl,baseDn,contextFactory,bindDn,password,authenticationMethod,
                              extraPropertiesEntries){
+
+    var self=this;
+    this.modified=ko.observable(false);
+
     //private String hostName;
     this.hostName=ko.observable(hostName);
+    this.hostName.subscribe(function(newValue){self.modified(true)});
 
     //private String port;
     this.port=ko.observable(port);
+    this.port.subscribe(function(newValue){self.modified(true)});
 
     //private boolean ssl = false;
     this.ssl=ko.observable(ssl);
+    this.ssl.subscribe(function(newValue){self.modified(true)});
 
     //private String baseDn;
     this.baseDn=ko.observable(baseDn);
+    this.baseDn.subscribe(function(newValue){self.modified(true)});
 
     //private String contextFactory;
     this.contextFactory=ko.observable(contextFactory);
+    this.contextFactory.subscribe(function(newValue){self.modified(true)});
 
     //private String bindDn;
     this.bindDn=ko.observable(bindDn);
+    this.bindDn.subscribe(function(newValue){self.modified(true)});
 
     //private String password;
     this.password=ko.observable(password);
+    this.password.subscribe(function(newValue){self.modified(true)});
 
     //private String authenticationMethod;
     this.authenticationMethod=ko.observable(authenticationMethod);
+    this.authenticationMethod.subscribe(function(newValue){self.modified(true)});
 
     this.extraPropertiesEntries=ko.observableArray(extraPropertiesEntries);
+    this.extraPropertiesEntries.subscribe(function(newValue){self.modified(true)});
   }
 
   mapLdapConfiguration=function(data){
@@ -1259,8 +1291,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
     }
 
     userManagerImplMoved=function(arg){
-      $.log("userManagerImplMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
-      //self.usedUserManagerImpls().push(self.availableUserManagerImpls()[arg.sourceIndex]);
+      $.log("userManagerImplMoved");
+      self.archivaRuntimeConfiguration().modified(true);
     }
 
     saveArchivaRuntimeConfiguration=function(){
index 343ddef077a37b71828edb2aa912131ade812542..55aae137118c48655baccf6cc6321525b07768eb 100644 (file)
@@ -355,11 +355,18 @@ require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i
    * mapping for a java Map entry
    * @param key
    * @param value
+   * @param subscribeFn if any will be called as subscrible function field
    */
-  Entry=function(key,value){
+  Entry=function(key,value,subscribeFn){
     var self=this;
     this.key=ko.observable(key);
+    if(subscribeFn){
+      this.key.subscribe(function(newValue){subscribeFn(newValue)});
+    }
     this.value=ko.observable(value);
+    if(subscribeFn){
+      this.value.subscribe(function(newValue){$.log("value modified");subscribeFn(newValue);});
+    }
   }
 
   /**
index 70de4ca4a69508b656c2c13df19ec8caf9b47e44..7c86a4113682be26f4b3cfa614c945d495527752 100644 (file)
       <div class="well">
         <div class="row-fluid">
           <div class="span4 dotted">
-            <h5></h5>
-            <hr/>
+            <h5>${$.i18n.prop('redback.runtime.user-managers.impls.choosed')}</h5>
             <div style="min-height: 40px" id="user-mananagers-sortables-choosed"
-                 data-bind="sortable: { template: 'redback-runtime-general-content-usermanagers', data:usedUserManagerImpls}">
+                 data-bind="sortable: { template: 'redback-runtime-general-content-usermanagers', data:usedUserManagerImpls,afterMove: userManagerImplMoved}">
             </div>
           </div>
 
           <div class="span4 dotted">
-            <h5></h5>
-            <hr/>
+            <h5>${$.i18n.prop('redback.runtime.user-managers.impls.available')}</h5>
             <div style="min-height: 40px"id="user-mananagers-sortables-availables"
-                 data-bind="sortable: {template: 'redback-runtime-general-content-usermanagers',data:availableUserManagerImpls}">
+                 data-bind="sortable: {template: 'redback-runtime-general-content-usermanagers',data:availableUserManagerImpls,afterMove: userManagerImplMoved}">
             </div>
           </div>
         </div>
           <thead>
             <tr>
               <th></th>
-              <th>key</th>
-              <th>value</th>
+              <th>${$.i18n.prop('redback.runtime.properties.key.label')}</th>
+              <th>${$.i18n.prop('redback.runtime.properties.value.label')}</th>
             </tr>
           </thead>
           <tbody>
 
         </table>
       </div>
-    </div>
   </div>
 
   <div>
-    <button data-bind="click: saveArchivaRuntimeConfiguration" id="archiva-runtime-configuration-save"
-            class="btn">${$.i18n.prop('save')}
-    </button>
+    <button data-bind="click: saveArchivaRuntimeConfiguration,css:{ 'btn-warning': archivaRuntimeConfiguration().modified() | archivaRuntimeConfiguration().ldapConfiguration().modified()  }"
+            id="archiva-runtime-configuration-save"class="btn">${$.i18n.prop('save')}</button>
   </div>
 
 </script>
 
+<script id="configurationPropertiesEntries-tmpl" type="text/html">
+
+</script>
+
 <script id="redback-runtime-general-content-usermanagers" type="text/html">
   <div class="well draggable-item">
     ${$data.description}