Skip to content

Commit

Permalink
use bootstrap in manage forms and remove resize buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jhinghaus authored and Michael Howitz committed Aug 17, 2018
1 parent 28e3c62 commit 362de51
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 178 deletions.
25 changes: 1 addition & 24 deletions src/Products/PythonScripts/PythonScript.py
Expand Up @@ -145,7 +145,7 @@ def __init__(self, id):
'Change Python Scripts',
'ZPythonScriptHTML_editAction',
'ZPythonScript_setTitle', 'ZPythonScript_edit',
'ZPythonScriptHTML_upload', 'ZPythonScriptHTML_changePrefs')
'ZPythonScriptHTML_upload', )

def ZPythonScriptHTML_editAction(self, REQUEST, title, params, body):
"""Change the script's main parameters."""
Expand Down Expand Up @@ -187,29 +187,6 @@ def ZPythonScriptHTML_upload(self, REQUEST, file=''):
return self.ZPythonScriptHTML_editForm(self, REQUEST,
manage_tabs_message=message)

def ZPythonScriptHTML_changePrefs(self, REQUEST, height=None, width=None,
dtpref_cols="100%", dtpref_rows="20"):
"""Change editing preferences."""
dr = {"Taller": 5, "Shorter": -5}.get(height, 0)
dc = {"Wider": 5, "Narrower": -5}.get(width, 0)
if isinstance(height, int):
dtpref_rows = height
if (isinstance(width, int) or
isinstance(width, str) and width.endswith('%')):
dtpref_cols = width
rows = str(max(1, int(dtpref_rows) + dr))
cols = str(dtpref_cols)
if cols.endswith('%'):
cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
else:
cols = str(max(35, int(cols) + dc))
e = (DateTime("GMT") + 365).rfc822()
setCookie = REQUEST["RESPONSE"].setCookie
setCookie("dtpref_rows", rows, path='/', expires=e)
setCookie("dtpref_cols", cols, path='/', expires=e)
REQUEST.other.update({"dtpref_cols": cols, "dtpref_rows": rows})
return self.manage_main(self, REQUEST)

def ZScriptHTML_tryParams(self):
"""Parameters to test the script with."""
param_names = []
Expand Down
48 changes: 15 additions & 33 deletions src/Products/PythonScripts/www/pyScriptAdd.dtml
@@ -1,5 +1,7 @@
<dtml-var manage_page_header>

<main>

<dtml-var "manage_form_title(this(), _,
form_title='Add Python Script',
)">
Expand All @@ -11,42 +13,22 @@ the script from a local file by typing the file name or using the
<em>browse</em> button.
</p>

<form action="manage_addPythonScript" method="post"
enctype="multipart/form-data">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top">
<div class="form-label">
Id
<form action="manage_addPythonScript" method="post"
enctype="multipart/form-data" class="zmi-add zmi-script zmi-python">
<div class="form-group row">
<label for="id" class="form-label col-sm-2">Id</label>
<input id="id" class="form-control col-sm-9 col-md-6" type="text" name="id" size="40" />
</div>
</td>
<td align="left" valign="top">
<input type="text" name="id" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-optional">
File
<div class="form-group row">
<label for="file-data" class="form-label col-sm-2">File</label>
<input id="file-data" class="form-control-file col-sm-9 col-md-6" type="file" name="file" size="25" value="" />
</div>
</td>
<td align="left" valign="top">
<input type="file" name="file" size="25" value="" />
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="submit"
value=" Add " />
<input class="form-element" type="submit" name="submit"
value=" Add and Edit " />
<div class="controls">
<input class="btn btn-primary" type="submit" name="submit" value=" Add " />
<input class="btn btn-primary" type="submit" name="submit" value=" Add and Edit " />
</div>
</td>
</tr>
</table>
</form>

</main>

<dtml-var manage_page_footer>
141 changes: 45 additions & 96 deletions src/Products/PythonScripts/www/pyScriptEdit.dtml
@@ -1,143 +1,92 @@
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<main>

<form action="&dtml-URL1;" method="post">
<input type="hidden" name=":default_method" value="ZPythonScriptHTML_changePrefs">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<form action="&dtml-URL1;" method="post" class="zmi-edit zmi-script zmi-python">

<dtml-with keyword_args mapping>
<tr>
<td align="left" valign="top">
<div class="form-optional">
Title
<div class="form-group row ">
<label for="title" class="form-label col-sm-3 col-md-3">
Title
</label>
<input id="title" class="form-control col-sm-9 col-md-6" type="text" name="title" size="40"
value="&dtml-title;" />
</div>
</td>
<td align="left" valign="top" width="99%">
<input type="text" name="title" size="40"
value="&dtml-title;" />
</td>
</tr>
<tr>
<td align="left" valign="top" nowrap>
<div class="form-optional">
Parameter List
<div class="form-group row ">
<label for="params" class="form-label col-sm-3 col-md-3">
Parameter List
</label>
<input id="params" class="form-control col-sm-9 col-md-6" type="text" name="params" size="40"
value="&dtml-params;" />
</div>
</td>
<td align="left" valign="top">
<input type="text" name="params" size="40"
value="&dtml-params;" />
</td>
</tr>
</dtml-with>
<dtml-with getBindingAssignments>
<dtml-if getAssignedNamesInOrder>
<tr>
<td align="left" valign="top">
<div class="form-label">
<div class="form-group row ">
<label for="bound" class="form-label col-sm-3 col-md-3">
Bound Names
</div>
</td>
<td align="left" valign="top">
<div class="form-text">
</label>
<div id="bound" class="form-text col-sm-9 col-md-6">
<dtml-in getAssignedNamesInOrder>
&dtml-sequence-item;<dtml-unless sequence-end>, </dtml-unless>
</dtml-in>
</div>
</td>
</tr>
</div>
</dtml-if>
</dtml-with>

<dtml-if errors>
<tr>
<td align="left" valign="middle" class="form-label">Errors</td>
<td align="left" valign="middle" style="background-color: #FFDDDD">
<pre><dtml-var expr="'\n'.join(errors)" html_quote></pre>
</td>
</tr>
<div class="alert alert-danger" role="alert">
<pre><dtml-var expr="'\n'.join(errors)" html_quote></pre>
</div>
</dtml-if>

<dtml-if warnings>
<tr>
<td align="left" valign="middle" class="form-label">Warnings</td>
<td align="left" valign="middle" style="background-color: #FFEEDD">
<pre><dtml-var expr="'\n'.join(warnings)" html_quote></pre>
</td>
</tr>
<div class="alert alert-warning" role="alert">
<pre><dtml-var expr="'\n'.join(warnings)" html_quote></pre>
</div>
</dtml-if>

<dtml-with keyword_args mapping>
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="body:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="body:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;">&dtml-body;</textarea>
</dtml-let>
</div>
</td>
</tr>
<textarea id="content" class="form-control zmi-zpt zmi-code col-sm-12"
name="body:text" wrap="off" rows="20">
&dtml-body;
</textarea>
</dtml-with>

<tr>
<td align="left" valign="top" colspan="2">
<div class="form-element">
<div class="controls mt-2">
<dtml-if wl_isLocked>
<em>Locked</em>
<dtml-else>
<input class="form-element" type="submit"
<input class="btn btn-primary" type="submit"
name="ZPythonScriptHTML_editAction:method" value="Save Changes">
</dtml-if>
&nbsp;&nbsp;
<input class="form-element" type="submit" name="height" value="Taller">
<input class="form-element" type="submit" name="height" value="Shorter">
<input class="form-element" type="submit" name="width" value="Wider">
<input class="form-element" type="submit" name="width" value="Narrower">
</div>
</td>
</tr>
</table>
</form>

<p class="form-help">
You may upload the source for &dtml-title_and_id; using the form below.
Choose an existing file from your local computer by clicking <em>browse</em>
The contents of the file should be a valid script with an optional
&quot;##data&quot; block at the start. You may click the following link
You may upload the source for &dtml-title_and_id; using the form below.
Choose an existing file from your local computer by clicking <em>browse</em>
The contents of the file should be a valid script with an optional
&quot;##data&quot; block at the start. You may click the following link
to <a href="document_src">view or download</a> the current source.
</p>

<form action="ZPythonScriptHTML_upload" method="post"
enctype="multipart/form-data">
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td align="left" valign="top">
<div class="form-label">
File &nbsp;
</div>
</td>
<td align="left" valign="top">
<input type="file" name="file" size="25" value="">
</td>
</tr>
<tr>
<td></td>
<td align="left" valign="top">
<div class="form-element">
<form action="ZPythonScriptHTML_upload" method="post"
enctype="multipart/form-data" class="zmi-upload">
<div class="form-group row">
<label for="file-data" class="col-sm-3 col-md-2">File</label>
<input id="file-data" class="form-control-file col-sm-9 col-md-6" type="file" name="file" size="25" value="">
</div>
<div class="controls">
<dtml-if wl_isLocked>
<em>Locked</em>
<dtml-else>
<input class="form-element" type="submit" value="Upload File">
<input class="btn btn-primary" type="submit" value="Upload File">
</dtml-if>
</div>
</td>
</tr>
</table>
</form>

</main>

<dtml-var manage_page_footer>
39 changes: 14 additions & 25 deletions src/Products/PythonScripts/www/pyScriptProxy.dtml
@@ -1,45 +1,34 @@
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<main>

<p class="form-help">
Proxy roles allow you to control the access that a script has. Proxy roles
replace the roles of the user who is executing the script. This can be used
to both expand and limit access to resources. Select the proxy roles for
Proxy roles allow you to control the access that a script has. Proxy roles
replace the roles of the user who is executing the script. This can be used
to both expand and limit access to resources. Select the proxy roles for
this object from the list below.
</p>

<form action="manage_proxy" method="post">
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
<form action="manage_proxy" method="post" class="zmi-proxy">
<div class="form-group row">
<label for="roles" class="form-label col-sm-3 col-md-2">
Proxy Roles
</div>
</td>
<td align="left" valign="top">
<div class="form-element">
<select name="roles:list" size="7" multiple>
</label>
<select id="roles" class="form-control col-sm-9 col-md-6" name="roles:list" size="7" multiple>
<dtml-in valid_roles>
<dtml-if expr="_vars['sequence-item'] != 'Shared'">
<option <dtml-if
<option <dtml-if
expr="manage_haveProxy(_vars['sequence-item'])">selected</dtml-if
>>&dtml-sequence-item;</option>
</dtml-if>
</dtml-in valid_roles>
</select>
</div>
</td>
</tr>
<tr>
<td align="left" valign="top" colspan="2">
<div class="form-element">
<input class="form-element" type="submit" name="SUBMIT" value="Save Changes">

<div class="controls">
<input class="btn btn-primary" type="submit" name="SUBMIT" value="Save Changes">
</div>
</td>
</tr>
</table>

</form>

</main>
<dtml-var manage_page_footer>

0 comments on commit 362de51

Please sign in to comment.