Changeset 866fc1


Ignore:
Timestamp:
Jun 16, 2010, 2:14:01 PM (9 years ago)
Author:
rene <rene@…>
Branches:
multiEdit
Parents:
c8e38d
Message:

first attempt, problems with returnValue fo dialog

Location:
chrome
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/vI_identityData.js

    rc8e38d r866fc1  
    8888
    8989    // copys all values of an identity. This way we can create a new object with a different document-context
    90     copy : function(identityData) {
    91         this.email = identityData.email;
    92         this.fullName = identityData.fullName;
    93         this.id.key = identityData.id.key;
    94         this.smtp.key = identityData.smtp.key;
    95         this.sideDescription = identityData.sideDescription;
    96         this.extras.copy(identityData.extras);
     90    // the (optional) keepOldOnEmpty parameter tells if it should keep the old value if there is no new value in parameter
     91    copy : function(identityData, keepOldOnEmpty) {
     92        if (!keepOldOnEmpty || identityData.email) this.email = identityData.email;
     93        if (!keepOldOnEmpty || identityData.fullName) this.fullName = identityData.fullName;
     94        if (!keepOldOnEmpty || identityData.id.key) this.id.key = identityData.id.key;
     95        if (!keepOldOnEmpty || identityData.smtp.key) this.smtp.key = identityData.smtp.key;
     96        if (!keepOldOnEmpty || identityData.sideDescription) this.sideDescription = identityData.sideDescription;
     97        this.extras.copy(identityData.extras, keepOldOnEmpty);
    9798    },
    9899
     
    236237};
    237238
    238 const DEFAULT_SMTP_TAG = "vI_useDefaultSMTP"
    239 const NO_SMTP_TAG = "vI_noStoredSMTP"
     239const DEFAULT_SMTP_TAG = "vI_useDefaultSMTP";
     240const NO_SMTP_TAG = "vI_noStoredSMTP";
    240241
    241242function vI_smtpObj(key) {
  • chrome/content/v_identity/vI_rdfDataEditor.js

    rc8e38d r866fc1  
    5050        vI_rdfDataEditor.__type = window.arguments[1];
    5151        vI_rdfDataEditor.__rdfDatasource = window.arguments[2];
    52         vI_rdfDataEditor.__rdfDataTree = window.arguments[3];
    53         ;
     52       
    5453        vI_rdfDataEditor.__identityData = new vI_identityData();
    5554        vI_rdfDataEditor.__identityData.copy(window.arguments[0].identityData);
    5655
    57        
     56        if (vI_rdfDataEditor.__recipient == "vI_groupModifyTemplate")
     57            document.getElementById("recipient_box").setAttribute("hidden", "true")
    5858        // set recipient
    5959        document.getElementById("recipient").value = vI_rdfDataEditor.__recipient;
     
    107107        localIdentityData.extras.readEditorValues();
    108108
    109         vI_rdfDataEditor.__rdfDatasource.updateRDF(
    110                 document.getElementById("recipient").value,
    111                 document.getElementById("type_menu").selectedItem.getAttribute("key"),
    112                 localIdentityData,
    113                 true, true, vI_rdfDataEditor.__recipient, vI_rdfDataEditor.__type);
     109        if (vI_rdfDataEditor.__recipient != "vI_groupModifyTemplate")
     110            vI_rdfDataEditor.__rdfDatasource.updateRDF(
     111                    document.getElementById("recipient").value,
     112                    document.getElementById("type_menu").selectedItem.getAttribute("key"),
     113                    localIdentityData,
     114                    true, true, vI_rdfDataEditor.__recipient, vI_rdfDataEditor.__type);
    114115       
    115         return document.getElementById("type_menu").selectedItem.getAttribute("key");
     116        var returnVar = {
     117            treeType: document.getElementById("type_menu").selectedItem.getAttribute("key"),
     118            identityData: localIdentityData
     119        }
     120
     121        return returnVar;
    116122    }
    117123}
  • chrome/content/v_identity/vI_rdfDataEditor.xul

    rc8e38d r866fc1  
    3333    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    3434    onload="vI_rdfDataEditor.init();"
    35     ondialogaccept="window.arguments[3].treeType = vI_rdfDataEditor.accept();"
     35    ondialogaccept="var retVal = vI_rdfDataEditor.accept(); window.arguments[3].treeType = retVal.treeType; window.arguments[3].identityData = retVal.identityData;"
    3636    title="&vI_rdfDataEditor.dlgTitle.label;" >
    3737
     38<script type="application/x-javascript" src="chrome://v_identity/content/vI_identityData.js" />
    3839<script type="application/x-javascript" src="chrome://v_identity/content/vI_rdfDataEditor.js" />
    39 <script type="application/x-javascript" src="chrome://v_identity/content/vI_identityData.js" />
    4040<script type="application/x-javascript" src="chrome://v_identity/content/vI_storageExtras.js" />
    4141<script type="application/x-javascript" src="chrome://v_identity/content/vI_storage.js" />
     
    5353    <dialogheader title="&vI_rdfDataEditor.header.label;"/>
    5454    <vbox id="vI_rdfDataEditorContent">
    55     <hbox>
     55    <hbox id="recipient_box">
    5656        <vbox><spacer flex="1"/>
    5757            <label value="&vI_rdfDataEditor.recipient.label;" accesskey="&vI_rdfDataEditor.recipient.accesskey;" control="recipient"/>
  • chrome/content/v_identity/vI_rdfDataTree.js

    rc8e38d r866fc1  
    150150   
    151151    onselect : function () {
     152        vI_rdfDataTree.groupUpdateConstraints();
    152153        vI_rdfDataTree.moveConstraints();
    153154
     
    282283    },
    283284
     285    groupModifySelected : function() {
     286        var treeType = vI_rdfDataTree.tabbox.selectedPanel.id;
     287        var tree = vI_rdfDataTree.trees[treeType];
     288        if (tree.treeElem.view.selection.count < 1) return; // shouldn't happen, button should not be shown if none or one selected
     289       
     290        // Open Dialog as for new Elem
     291        var newItemPreset = { recipientCol : "vI_groupModifyTemplate", identityData : new vI_identityData ("", null, null, NO_SMTP_TAG, null, null) };
     292        // XXXX create useful preset
     293        var retVar = { treeType: null, identityData: new vI_identityData() };
     294
     295        window.openDialog("chrome://v_identity/content/vI_rdfDataEditor.xul",0,
     296            "chrome, dialog, modal, alwaysRaised, resizable=yes",
     297            newItemPreset, treeType,
     298            vI_rdfDatasource, retVar).focus();
     299
     300        var warning = vI_rdfDataTree._strings.getString("vI_rdfDataTree.modify.Warning1") + " " +
     301            tree.treeElem.view.selection.count + " " +
     302            vI_rdfDataTree._strings.getString("vI_rdfDataTree.modify.Warning2")
     303        if (!vI_rdfDataTree.promptService.confirm(window,"Warning",warning)) return;
     304
     305        var start = new Object(); var end = new Object();
     306        var numRanges = tree.treeElem.view.selection.getRangeCount();
     307        for (var t=0; t<numRanges; t++){
     308            tree.treeElem.view.selection.getRangeAt(t,start,end);
     309            for (var v=start.value; v<=end.value; v++) {
     310                var localIdentityData = new vI_identityData();
     311                vI_notificationBar.dump("## groupModifySelected created new identityData\n");
     312                localIdentityData.copy(tree.idTable[v].identityData, false);
     313                vI_notificationBar.dump("## groupModifySelected added previous identityData\n");
     314                vI_notificationBar.dump("## groupModifySelected const DEFAULT_SMTP_TAG = " + DEFAULT_SMTP_TAG + "\n");
     315                // copy all defined settings from retVal.identityData to localIdentityData
     316                localIdentityData.copy(retVar.identityData, true);
     317                vI_notificationBar.dump("## groupModifySelected overtook new identityData\n");
     318                vI_rdfDatasource.updateRDF(
     319                    tree.idTable[v]["recipientCol"], treeType,
     320                    localIdentityData,
     321                    true, true, tree.idTable[v]["recipientCol"], treeType);
     322            }
     323        }
     324
     325        // reload all trees (multiple types might have changed)
     326        for each (var treeType in vI_rdfDataTree.treeTypes) {
     327            vI_rdfDataTree.trees[treeType].idData = null;
     328            vI_rdfDataTree.trees[treeType].idTable = null;
     329            vI_rdfDataTree.trees[treeType].loadTable()
     330        }
     331        vI_rdfDataTree.tabbox.selectedTab = document.getElementById(retVar.treeType + "Tab");
     332        vI_rdfDataTree.hideInfoBox();
     333    },
     334
    284335    modifySelected : function() {
    285336        var treeType = vI_rdfDataTree.tabbox.selectedPanel.id;
     
    340391        vI_rdfDataTree.hideInfoBox();
    341392    },
     393
     394    groupUpdateConstraints : function() {
     395        var treeType = vI_rdfDataTree.tabbox.selectedPanel.id;
     396        var tree = vI_rdfDataTree.trees[treeType];
     397        if (tree.treeElem.view.selection.count > 1)
     398            document.getElementById("groupEditButton_" + treeType).setAttribute("disabled","false");
     399        else    document.getElementById("groupEditButton_" + treeType).setAttribute("disabled","true");
     400    },
    342401   
    343402    moveConstraints : function() {
  • chrome/content/v_identity/vI_rdfDataTree.xul

    rc8e38d r866fc1  
    4848    title="&vI_rdfDataTree.dlgTitle.label;">
    4949
     50<script type="application/x-javascript" src="chrome://v_identity/content/vI_identityData.js" />
    5051<script type="application/x-javascript" src="chrome://v_identity/content/vI_rdfDataTree.js" />
    51 <script type="application/x-javascript" src="chrome://v_identity/content/vI_identityData.js" />
    5252<script type="application/x-javascript" src="chrome://v_identity/content/vI_helper.js" />
    5353<script type="application/x-javascript" src="chrome://v_identity/content/vI_rdfDatasource.js" />
     
    162162                  oncommand="vI_rdfDataTree.removeSelected();"/>
    163163          <spacer flex="1"/>
     164          <button id="groupEditButton_email" label="&vI_rdfDataTree.groupEditButton.label;" accesskey="&vI_rdfDataTree.groupEditButton.accesskey;"
     165                  oncommand="vI_rdfDataTree.groupModifySelected();" disabled="true"/>
    164166</vbox>
    165167</hbox>
     
    199201                  oncommand="vI_rdfDataTree.removeSelected();"/>
    200202          <spacer flex="1"/>
     203      <button id="groupEditButton_maillist" label="&vI_rdfDataTree.groupEditButton.label;" accesskey="&vI_rdfDataTree.groupEditButton.accesskey;"
     204                  oncommand="vI_rdfDataTree.groupModifySelected();" disabled="true"/>
    201205</vbox>
    202206</hbox>
     
    235239                  oncommand="vI_rdfDataTree.removeSelected();"/>
    236240          <spacer flex="1"/>
     241      <button id="groupEditButton_newsgroup" label="&vI_rdfDataTree.groupEditButton.label;" accesskey="&vI_rdfDataTree.groupEditButton.accesskey;"
     242                  oncommand="vI_rdfDataTree.groupModifySelected();" disabled="true"/>
    237243</vbox>
    238244</hbox>
     
    283289                  oncommand="vI_rdfDataTree.moveDownSelected();"/>
    284290          <spacer flex="1"/>
     291      <button id="groupEditButton_filter" label="&vI_rdfDataTree.groupEditButton.label;" accesskey="&vI_rdfDataTree.groupEditButton.accesskey;"
     292                  oncommand="vI_rdfDataTree.groupModifySelected();" disabled="true"/>
    285293</vbox>
    286294</hbox>
  • chrome/content/v_identity/vI_storageExtras.js

    rc8e38d r866fc1  
    116116   
    117117    // copys all values of an identity. This way we can create a new object with a different document-context
    118     copy : function(extras) {
    119         if (vI_storageExtrasHelper.seamonkey_to_old()) return;
    120         for( var i = 0; i < this.extras.length; i++ ) {
    121             this.extras[i].value = extras.extras[i].value;
     118    // the (optional) keepOldOnEmpty parameter tells if it should keep the old value if there is no new value in parameter
     119    copy : function(extras, keepOldOnEmpty) {
     120        if (vI_storageExtrasHelper.seamonkey_to_old()) return;
     121        for( var i = 0; i < this.extras.length; i++ ) {
     122            if (!keepOldOnEmpty || extras.extras[i].value) this.extras[i].value = extras.extras[i].value;
    122123        }
    123124    },
  • chrome/locale/en-US/v_identity/vI_rdfDataTree.dtd

    rc8e38d r866fc1  
    2222<!ENTITY vI_rdfDataTree.newItem.accesskey "N">
    2323
     24<!ENTITY vI_rdfDataTree.groupEditButton.label "Group Edit">
     25<!ENTITY vI_rdfDataTree.groupEditButton.accesskey "G">
Note: See TracChangeset for help on using the changeset viewer.