appypod-rattail/gen/ui/import.pt
2011-12-05 15:11:29 +01:00

112 lines
4.7 KiB
XML

<tal:main define="tool context/config">
<html metal:use-macro="context/ui/template/macros/main">
<metal:fill fill-slot="content"
tal:define="className request/className;
importElems python: tool.getImportElements(className);
global allAreImported python:True">
<div metal:use-macro="context/ui/page/macros/prologue"/>
<script language="javascript">
<!--
var importedElemsShown = false;
function toggleViewableElements() {
var rows = document.getElementsByName('importedElem');
var newDisplay = 'table-row';
if (isIe) newDisplay = 'block';
if (importedElemsShown) newDisplay = 'none';
for (var i=0; i<rows.length; i++) {
rows[i].style.display = newDisplay;
}
importedElemsShown = !importedElemsShown;
}
var checkBoxesChecked = true;
function toggleCheckboxes() {
var checkBoxes = document.getElementsByName('cbElem');
var newCheckValue = true;
if (checkBoxesChecked) newCheckValue = false;
for (var i=0; i<checkBoxes.length; i++) {
checkBoxes[i].checked = newCheckValue;
}
checkBoxesChecked = newCheckValue;
}
function importSingleElement(importPath) {
var f = document.forms['importElements'];
f.importPath.value = importPath;
f.submit();
}
function importManyElements() {
var f = document.forms['importElements'];
var importPaths = '';
// Get the values of the checkboxes
var checkBoxes = document.getElementsByName('cbElem');
for (var i=0; i<checkBoxes.length; i++) {
if (checkBoxes[i].checked) {
importPaths += checkBoxes[i].value + '|';
}
}
if (! importPaths) alert(no_elem_selected);
else {
f.importPath.value = importPaths;
f.submit();
}
}
-->
</script>
<tal:comment replace="nothing">Form for importing several meetings at once.</tal:comment>
<form name="importElements"
tal:attributes="action python: tool.absolute_url()+'/do'" method="post">
<input type="hidden" name="action" value="ImportObjects"/>
<input type="hidden" name="className" tal:attributes="value className"/>
<input type="hidden" name="importPath" value=""/>
</form>
<h1 tal:content="python: tool.translate('import_title')"></h1><br/>
<table class="list" width="100%">
<tr>
<th tal:repeat="columnHeader python: importElems[0]">
<img tal:condition="python: repeat['columnHeader'].number() == 1"
tal:attributes="src string:$appUrl/ui/eye.png;
title python: tool.translate('import_show_hide')"
style="cursor:pointer" onClick="toggleViewableElements()" align="left" />
<span tal:replace="columnHeader"/>
</th>
<th tal:content="python: tool.translate('ref_actions')"></th>
<th width="20px"><img
tal:attributes="src string: $appUrl/ui/select_elems.png;
title python: tool.translate('select_delesect')"
onClick="toggleCheckboxes()" style="cursor:pointer"/>
</tr>
<tal:row repeat="row python: importElems[1]">
<tr tal:define="alreadyImported python: tool.isAlreadyImported(className, row[0]);
global allAreImported python: allAreImported and alreadyImported;
odd repeat/row/odd"
tal:attributes="id python: alreadyImported and 'importedElem' or 'notImportedElem';
name python: alreadyImported and 'importedElem' or 'notImportedElem';
style python: alreadyImported and 'display:none' or 'display:table-row';
class python: odd and 'even' or 'odd'">
<td tal:repeat="elem python: row[1:]" tal:content="elem">
</td>
<td>
<input type="button" tal:condition="not: alreadyImported"
tal:attributes="onClick python: 'importSingleElement(\'%s\')' % row[0];
value python: tool.translate('query_import')"/>
<span tal:condition="alreadyImported" tal:replace="python: tool.translate('import_already')"/>
</td>
<td align="center">
<input type="checkbox" checked="checked" id="cbElem" name="cbElem"
tal:attributes="value python: row[0]" tal:condition="not: alreadyImported"/>
</td>
</tr>
</tal:row>
<tr tal:condition="python: not importElems[1] or allAreImported"><td colspan="15" tal:content="python: tool.translate('query_no_result')"></td></tr>
</table>
<tal:comment replace="nothing">Button for importing several elements at once.</tal:comment>
<p align="right"><br/>
<input type="button" onClick="importManyElements()"
tal:condition="python: importElems[1] and not allAreImported"
tal:attributes="value python:tool.translate('import_many')"/>
</p>
</metal:fill>
</html>
</tal:main>