summaryrefslogtreecommitdiffstats
path: root/google-appengine/google/appengine/ext/admin/templates/datastore_edit.html
blob: 0e2247a42519143c7e9e31b674d2f2afb5aebb47 (plain) (blame)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
{% extends "base.html" %}

{% block title %}{{ application_name }} Development Console - Datastore Viewer - {% if key %}Edit Entity{% else %}New Entity{% endif %}{% endblock %}

{% block head %}
  <style type="text/css">{% include "css/form.css" %}</style>
  <style type="text/css">

  .field_type {
    color: gray;
    font-weight: normal;
  }

  </style>
  <script type="text/javascript">

  function load() {
    var elements = document.getElementsByTagName("input");
    for (var i = 0; i < elements.length; i++) {
      var element = elements[i];
      var hint = null;
      if (element.className == "time") {
        hint = "e.g., 2006-30-05 23:56:04";
      }
      if (hint) registerHint(element, hint);
    }
  }

  function registerHint(element, hint) {
    function showDefault() {
      if (element.value.length == 0 || element.value == hint) {
        element.style.color = "gray";
        element.value = hint;
      }
    }
    function clearDefault() {
      if (element.style.color == "gray" || element.value == hint) {
        element.value = "";
        element.style.color = "black";
      }
    }
    element.onblur = showDefault;
    element.onfocus = clearDefault;
    showDefault();
  }

  function clearHints(form) {
    var elements = form.getElementsByTagName("input");
    for (var i = 0; i < elements.length; i++) {
      var element = elements[i];
      if (element.type == "text" && element.style.color == "gray") {
        element.onblur = null;
        element.onfocus = null;
        element.value = "";
      }
    }
    return true;
  }

  </script>
{% endblock %}

{% block bodyattributes %}onload="load()"{% endblock %}

{% block body %}
  <h3>{% if key %}Edit Entity{% else %}New Entity{% endif %}</h3>

  <form action="{{ request.path }}" method="post" onsubmit="return clearHints(this)">
    <div><input type="hidden" name="next" value="{{ next }}"/></div>
    <table class="form">
      <tr>
        <td class="name">Entity Kind</td>
        <td class="value text">
          {{ kind }}
          <input type="hidden" name="kind" value="{{ kind }}"/>
        </td>
      </tr>
      {% if key %}
        <tr>
          <td class="name">Entity Key</td>
          <td class="value text">
            {{ key }}
            <input type="hidden" name="key" value="{{ key }}"/>
          </td>
        </tr>
      {% endif %}
      {% if key_name %}
        <tr>
          <td class="name">Key Name</td>
          <td class="value text">
            {{ key_name }}
          </td>
        </tr>
      {% endif %}
      {% if key_id %}
        <tr>
          <td class="name">ID</td>
          <td class="value text">
            {{ key_id }}
          </td>
        </tr>
      {% endif %}
      {% if parent_key %}
        <tr>
          <td class="name">Parent</td>
          <td class="value text">
            {{ parent_key|escape }}<br />
            <a href="?key={{parent_key}}&kind={{parent_kind}}">{{ parent_key_string }}</a>
          </td>
        </tr>
      {% endif %}
      {% if not key %}
        {% if namespace %}
          <tr>
            <td class="name">
              <span class="field_name">Namespace</span>
              <span class="field_type">({{ namespace|escape }})</span>
            </td>
            <td class="value"><input type="text" name="namespace" value="{{ namespace|escape }}"/></td>
          </tr>
        {% endif %}
      {% endif %}
      {% for field in fields %}
        <tr>
          <td class="name">
            <span class="field_name">{{ field.0|escape }}</span>
            <span class="field_type">({{ field.1|escape }})</span>
          </td>
          <td class="value"><div style="position: relative">{{ field.2|safe }}</div></td>
        </tr>
      {% endfor %}
      <tr>
        <td></td>
        <td class="buttons">
          <input type="submit" value="Save Changes"/>
          {% if key %}
            <input type="submit" name="action" value="Delete" onclick="return confirm('Are you sure you want to permanently delete this entity?');"/>
          {% endif %}
        </td>
      </tr>
    </table>
  </form>

  <div id="datepicker"></div>
{% endblock %}

{% block final %}
<script type="text/javascript">
//<![CDATA[

// Sets the focus on the field with the given name in the given array (if any)
function setFocus(fields, fieldName) {
  for (var i = 0; i < fields.length; i++) {
    var field = fields[i];
    var name = field.name;
    if (field.focus && name.length > focus.length &&
        name.substring(name.length - focus.length - 1) == '|' + focus) {
      field.focus();
      break;
    }
  }
}

// Focus on the appropriate field in the form based on the "focus" argument
// in the URL
var focus = "{{ focus|addslashes }}";
if (focus) {
  setFocus(document.getElementsByTagName("input"), focus);
  setFocus(document.getElementsByTagName("textarea"), focus);
}

//]]>
</script>
{% endblock %}