proxyFieldEdit.dtml 6.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
<dtml-var manage_page_header>
<dtml-let help_product="'Formulator'" help_topic=meta_type>
<dtml-var manage_tabs>
</dtml-let>

<p class="form-help">
Surcharge <dtml-var meta_type> properties here.
</p>

<form action="manage_edit" method="POST">
<table cellspacing="0" cellpadding="2" border="0">
12 13
<dtml-let proxy_field="this()"
          current_field="proxy_field.getRecursiveTemplateField()">
14 15 16 17 18 19 20 21 22

  <!-- First, display ProxyField properties -->
  <!-- see: Formulator/dtml/fieldEdit.dtml -->
  <dtml-in "form.get_groups()">
  <dtml-let group=sequence-item fields="form.get_fields_in_group(group)">

  <dtml-if fields>
  <tr>
  <td colspan="3" class="form-title">
23
    Proxy Widget properties <dtml-if "current_field is not None">(<dtml-var expr="current_field.meta_type">)</dtml-if>
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
  </td>
  </tr>
  <dtml-var fieldListHeader>
  <dtml-let current_field="this()">
  <dtml-in fields>
  <dtml-let field=sequence-item field_id="field.id"
            value="current_field.get_orig_value(field_id)"
            override="current_field.get_override(field_id)"
            tales="current_field.get_tales(field_id)">
    <tr>
      <td align="left" valign="top">
      <div class="form-label">
      <dtml-if "tales or override">[</dtml-if><dtml-var "field.title()"><dtml-if "field.has_value('required') and field.get_value('required')">*</dtml-if><dtml-if "tales or override">]</dtml-if>
      </div>
      </td>
      <td align="left" valign="top">
      <dtml-var "field.render(value)">
      </td>
      <td><div class="form-element">
      <dtml-var "field.meta_type">
      </div></td>
    </tr>
  </dtml-let>
  </dtml-in>
  </dtml-let>
  </dtml-if>
  </dtml-let>
  </dtml-in>


<!-- Then, display Template Field properties -->
  
  <dtml-if "current_field is not None">
    <dtml-let form="current_field.form">

  <dtml-in "form.get_groups()">
    <dtml-let group=sequence-item fields="form.get_fields_in_group(group)">
      <dtml-if fields>
        <tr>
          <td colspan="3" class="form-title">
            <dtml-var "_.string.capitalize(group)"> properties
          </td>
        </tr>

        <dtml-var proxyFieldListHeader>

        <dtml-in fields>
        <dtml-let field=sequence-item field_id="field.id"
                  value="proxy_field.get_recursive_orig_value(field_id)"
                  override="proxy_field.get_recursive_override(field_id)"
                  tales="proxy_field.get_recursive_tales(field_id)">
          <tr>
            <td align="left" valign="top">
              <dtml-let checkbox_key="'surcharge_%s' % field_id" >
                <dtml-if "proxy_field.is_delegated(field_id)">
                  <input type="checkbox" 
                         name="<dtml-var checkbox_key>" 
81
                         onclick="toggleFieldState(event)"
82 83 84
                         checked="checked" />
                <dtml-else >
                  <input type="checkbox" 
85
                         onclick="toggleFieldState(event)"
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
                         name="<dtml-var checkbox_key>" />
                </dtml-if >
              </dtml-let >
            </td>
            <td align="left" valign="top">
            <div class="form-label">
              <dtml-if "tales or override">[
                </dtml-if>
                <dtml-var "field.title()">
                <dtml-if "field.has_value('required') and field.get_value('required')">*
                </dtml-if>
                <dtml-if "tales or override">]
              </dtml-if>
            </div>
            </td>
101 102 103 104 105 106 107 108 109
            <dtml-if "proxy_field.is_delegated(field_id)">
              <td align="left" valign="top" class="to_disable delegated">
              <dtml-var "field.render(value)">
              </td>
            <dtml-else >
              <td align="left" valign="top" class="to_disable">
              <dtml-var "field.render(value)">
              </td>
            </dtml-if>
110 111 112
            <td><div class="form-element">
            <dtml-var "field.meta_type">
            </div></td>
113 114 115
            <td><div class="form-element">
            <dtml-var "field.get_value('description')">
            </div></td>
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
          </tr>
        </dtml-let>
        </dtml-in>
      </dtml-if>
    </dtml-let>
  </dtml-in>

  </dtml-let>
  </dtml-if>
  </dtml-let>

    <tr>
      <td align="left" valign="top">
      <div class="form-element">
      <input class="form-element" type="submit" name="submit" 
       value="Save Changes" /> 
      </div>
      </td>
    </tr>



</table>
</form>

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
<script type="text/javascript">
function isClass(object, className) {
        if (object.className != undefined){
        return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);
        }
        return false;
}
function GetElementsWithClassName(elementName,className) {
        var allElements = document.getElementsByTagName(elementName);
        var elemColl = new Array();
        for (i = 0; i< allElements.length; i++) {
                if (isClass(allElements[i], className)) {
                        elemColl[elemColl.length] = allElements[i];
                }
        }
        return elemColl;
}
158 159 160
function normalEvent() { return true; }
function ignoreEvent() { return false; }

161 162 163 164 165 166 167 168
var last_selected;
function registerSelection() {
  last_selected = this.selectedIndex;
}
function dontChangeSelection() {
  this.selectedIndex = last_selected;
}

169
var class_deletaged_list = GetElementsWithClassName('td','delegated');
170
for(var i=0; i<class_deletaged_list.length; i++) {
171 172 173 174 175 176 177 178 179
  var disable_children = class_deletaged_list[i].childNodes;
  for (var j=0; j<disable_children.length; j++) {
    var element = disable_children[j];
    if (element.type == 'hidden'){
      continue;
    }
    element.readOnly = true;
    if (element.type == 'checkbox'){
      element.onclick = ignoreEvent;
180 181 182
    } else if (element.tagName == 'SELECT') {
      element.onfocus = registerSelection;
      element.onchange = dontChangeSelection;
183
    }
184
  }
185 186 187 188 189 190 191 192 193
}

function toggleFieldState(evt) {
  evt=(evt)?evt:event;
  var target=(evt.target)?evt.target:evt.srcElement;
  tr_parent = target.parentNode.parentNode;
  allElements = tr_parent.childNodes;
  for (i=0; i<allElements.length; i++) {
    if (isClass(allElements[i], 'to_disable')) {
194 195 196 197 198
      var disable_children = allElements[i].childNodes;
      for (var j=0; j<disable_children.length; j++) {
        var field = disable_children[j];
        if (field.type == 'hidden'){
          continue;
199
        }
200 201 202 203
        if (field.readOnly){
          field.readOnly = false;
          if (field.type == 'checkbox'){
            field.onclick = normalEvent;
204 205
          } else if (field.tagName == 'SELECT') {
            field.onchange = normalEvent;
206 207 208 209 210 211
          }
        }
        else{
          field.readOnly = true;
          if (field.type == 'checkbox'){
            field.onclick = ignoreEvent;
212 213 214
          } else if (field.tagName == 'SELECT') {
            field.onfocus = registerSelection;
            field.onchange = dontChangeSelection;
215
          }
216
        }
217 218 219 220 221
      }
    }
  }
}
</script>
222
<dtml-var manage_page_footer>