Line # Revision Author
1 8 ahitrov@rambler.ru <& "/contenido/components/title.msn", title=>'Создание связей' &>
2 <style>
3 <!--
4 body {margin:5px;}
5 -->
6 </style>
7
8 % if (ref $document) {
9 % ### Source is available
10 % ######################################################
11
12 <script language="JavaScript">
13 <!--
14 function DeleteDest ()
15 {
16 oSelect = document.forms['destform'].elements[0];
17 for (j = 0; j < oSelect.options.length; j++) {
18 if (!oSelect.options[j].selected) {
19 oSelect.options[j] = null;
20 }
21 }
22 return true;
23 }
24
25 function SelectAllDest ()
26 {
27 oSelect = document.forms['destform'].elements[0];
28 // oSelect.setExpression('multiple', true);
29 // document.recalc(true);
30 for (j = 0; j < oSelect.options.length; j++) {
31 oSelect.options[j].selected = true;
32 }
33 return true;
34 }
35
36 function CheckDest () {
37 var count = 0;
38 var oD = document.getElementById("dest_id_0");
39 var oC = document.getElementById("dest_class_0");
40 if ( oD && oC ) {
41 return true;
42 } else {
43 alert ('Не выбран ни один документ');
44 return false;
45 }
46 }
47
48 //-->
49 </script>
50
51 %
52 % my @properties = $document->structure();
53 % my ($prop) = grep { $_->{'attr'} eq 'status' } @properties;
54 % my ($status) = grep { $_->[0] == $document->status } @{ $m->comp( '/contenido/components/inputs/status.msn', prop => $prop, object=>$document, name => $prop->{attr}, mode => 'get') };
55 % $status = $status->[1];
56 <table width="100%" border="0" align="center"><tr><td>
57 <fieldset>
58 <legend>Источник</legend>
59 <table class="tform" width="100%">
60 <tr valign="top"><td><b>Название:</b>
61 </td><td><a href="/contenido/document.html?id=<% $document->id %>&class=<% $document->class %>" target="_top"><% $document->name %></a>
62 </td></tr>
63 <tr valign="top"><td><b>Класс:</b>
64 </td><td><% $document->class %>
65 </td></tr>
66 <tr valign="top"><td><b>Статус:</b>
67 </td><td><% $status %>
68 </td></tr>
69 </table>
70 </fieldset>
71
72 <fieldset>
73 <legend>Список связей</legend>
74
75 <form action="link_add.html" name="destform" target="_top" method="post" onsubmit="return CheckDest();">
76 <div id="link_list"></div>
77
78 <table class="tform" width="100%">
79 <tr><td>
80 <form action="link_add.html" name="destform" target="_top" method="post" onsubmit="return CheckDest();">
81 <select multiple name="destinations" size="20" style="width:100%">
82 </select>
83 <p>К источнику будут привязаны только выделенные документы.</p>
84 <input type="hidden" name="class" value="<% $class %>">
85 <input type="hidden" name="source_id" value="<% $source_id %>">
86 <input type="hidden" name="source_class" value="<% $source_class %>">
87 <input type="button" value="Выделить все" onclick="SelectAllDest();">
88 <input type="button" value="Удалить лишнее" onclick="DeleteDest();">
89 <input type="submit" value="Связать выбранное">
90 </td></tr>
91 </table>
92 </form>
93 </fieldset>
94
95 </td></tr></table>
96
97 %#<pre><% Dumper(\@properties) %></pre>
98
99 % }else{
100 % ### Source is not available
101 % ######################################################
102 %
103
104 <script language="JavaScript">
105 <!--
106 function AddSource (Value, Name)
107 {
108 // alert (Name);
109
110 var oSelect = parent.frames.destfrm.document.forms['sourceform'].elements[0];
111 var Found = 0;
112 for(j=0; j < oSelect.options.length; j++) {
113 if (oSelect.options[j].value == Value) {
114 Found = 1;
115 }
116 }
117 if (!Found) {
118 var oOption = document.createElement("OPTION");
119 oOption.text=Name;
120 oOption.value=Value;
121 oOption.selected=true;
122 oSelect.options.add(oOption);
123 }
124 return false;
125 }
126
127 //-->
128 </script>
129
130 <& /contenido/components/link_browse.msn,
131 class => $class,
132 source_class => $source_class,
133 p => $p,
134 use_section => $use_section,
135 alpha => $alpha,
136 alpha_search => $alpha_search,
137 search => $search,
138 search_by => $search_by,
139 restrict_class => $restrict_class,
140 &>
141
142 % }
143
144 </body>
145 </html>
146 <%args>
147 $class => ''
148 $source_class => ''
149 $source_id => ''
150 $dest_class => ''
151 $dest_id => ''
152 $save => 0
153 $status => 0
154
155 $p => 1
156 $restrict_class => undef
157 $use_section => undef
158 $alpha => undef
159 $alpha_search => undef
160 $search_by => undef
161 $search => undef
162
163 </%args>
164 <%init>
165
166 my $document;
167
168 if ($source_id) {
169 $document = $keeper->get_document_by_id ($source_id,
170 class => $source_class,
171 );
172 } else {
173 $source_class = $class->available_sources;
174 }
175
176 </%init>