summaryrefslogtreecommitdiffstats
path: root/extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl
blob: 0c968e63416c9a5ff7a56d93168393e8c62e9dbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
81
82
83
84
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[% RETURN UNLESS default.user_story_visible.0 && default.check_can_change_field('cf_user_story', 0, 1) %]

</tbody>
<tbody id="cf_user_story_container" class="expert_fields bz_default_hidden">
  <tr>
    <th class="field_label">
      <label for="cf_user_story">User Story:</label>
    </th>
    <td colspan="3">
      <div id="user_story_header">
          <span id="user_story_edit">
            (<a href="javascript:void(0)" id="user_story_edit_action" >edit</a>)
          </span>
      </div>
      <div id="user_story_edit_container" class="bz_default_hidden">
        [% user_story_default = cloned_bug ? cloned_bug.cf_user_story : default.cf_user_story %]
        [% INCLUDE global/textarea.html.tmpl
            name     = 'cf_user_story'
            id       = 'user_story'
            minrows  = 10
            maxrows  = 10
            cols     = constants.COMMENT_COLS
            disabled = 1
            defaultcontent = user_story_default
        %]
      </div>
      <script type="text/javascript">
        var user_story_exclude_components = [];
        [% FOREACH c = default.user_story_visible.1 %]
          user_story_exclude_components.push('[% c FILTER js %]');
        [% END %]
        function toggleUserStory() {
          if (YAHOO.util.Dom.get('user_story').value != '') {
            hideUserStoryEdit();
          }
          if (user_story_exclude_components.length == 0) {
            YAHOO.util.Dom.removeClass('cf_user_story_container', 'bz_default_hidden');
            YAHOO.util.Dom.get('user_story').disabled = false;
            return;
          }
          var index = -1;
          var form = document.Create;
          if (form.component.type == 'select-one') {
            index = form.component.selectedIndex;
          } else if (form.component.type == 'hidden') {
            // Assume there is only one component in the list
            index = 0;
          }
          if (index != -1) {
            for (var i = 0, l = user_story_exclude_components.length; i < l; i++) {
              if (user_story_exclude_components[i] == components[index]) {
                YAHOO.util.Dom.addClass('cf_user_story_container', 'bz_default_hidden');
                YAHOO.util.Dom.get('user_story').disabled = true;
                return;
              }
              else {
                YAHOO.util.Dom.removeClass('cf_user_story_container', 'bz_default_hidden');
                YAHOO.util.Dom.get('user_story').disabled = false;
              }
            }
          }
        }
        function hideUserStoryEdit() {
          YAHOO.util.Dom.addClass('user_story_edit', 'bz_default_hidden');
          YAHOO.util.Dom.addClass('user_story_readonly', 'bz_default_hidden');
          YAHOO.util.Dom.removeClass('user_story_edit_container', 'bz_default_hidden');
        }
        YAHOO.util.Event.addListener('component', 'change', toggleUserStory);
        YAHOO.util.Event.addListener('user_story_edit_action', 'click', function() {
          hideUserStoryEdit();
          YAHOO.util.Dom.get('user_story').focus();
        });
        toggleUserStory();
      </script>
    </td>
  </tr>