Wiki source code of MoccaCalendarEventSheet
Last modified by Andrey Che on 2018/12/10 14:09
Hide last authors
![]() |
1.1 | 1 | {{velocity output="false"}} |
2 | ### this macro shows a validation error message if it exists | ||
3 | #macro(showvalidationmessage $message $force) | ||
4 | #if($xcontext.validationStatus.errors.contains($message) || "$!force" == "true") ## | ||
5 | <span class="xErrorMsg">$escapetool.xml($services.localization.render($message))</span> | ||
6 | #else ## | ||
7 | ## | ||
8 | #end ## | ||
9 | #end ## end showvalidationmessage | ||
10 | ## | ||
11 | #macro(displayDate $field) | ||
12 | #if($xcontext.getAction()=="view" && $doc.getValue('allDay')==1) | ||
13 | #set($format = $!doc.getObject('MoccaCalendar.MoccaCalendarEventClass').getxWikiClass().get($field).getProperty('dateFormat').value) | ||
14 | #if($!format=="") | ||
15 | #set($format = $xwiki.getSpacePreference('dateformat', 'dd.MM.yyyy')) | ||
16 | #end | ||
17 | ## try to cut the time because this event has the all day flag | ||
18 | #set($idx=$format.indexOf("H")) | ||
19 | #if($idx>0) | ||
20 | #set($format = $format.substring(0,$idx).trim()) | ||
21 | #end | ||
22 | #set($formattedValue = $escapetool.xml($datetool.format($format, $doc.getValue($field)))) | ||
23 | $!formattedValue | ||
24 | #else | ||
25 | $doc.display($field) | ||
26 | #end | ||
27 | #end | ||
28 | ## | ||
29 | #set($discard=$xwiki.jsx.use("MoccaCalendar.DatePickerExtension", {'defer': false})) | ||
30 | #if($xcontext.getAction()=="edit") | ||
31 | #set($discard=$xwiki.jsx.use("MoccaCalendar.MoccaCalendarEventSheet")) | ||
32 | #end | ||
33 | #set($calendar = $parentDoc.getObject('MoccaCalendar.MoccaCalendarClass')) | ||
34 | #if($calendar) | ||
35 | #set($calendarDoc = $parentDoc) | ||
36 | #end | ||
37 | #if(!$calendar && "$!request.getParameter('parentFROM')" != "") | ||
38 | #set($calendarDoc = $xwiki.getDocument($request.getParameter('parentFROM'))) | ||
39 | #set($calendar = $calendarDoc.getObject('MoccaCalendar.MoccaCalendarClass')) | ||
40 | #end | ||
41 | #set($backToCalendarDoc = $xwiki.getDocument($request.getParameter('calendarDoc'))) | ||
42 | #if(!$!backToCalendarDoc || $backToCalendarDoc.isNew()) | ||
43 | #set($backToCalendarDoc = $calendarDoc) | ||
44 | #end | ||
45 | #if($xcontext.getAction()=="edit") | ||
46 | #if($request.xpage=="plain") | ||
47 | ## we are in modal dialog edit view - no separate parent page widget | ||
48 | #set($parentParamName="parent") | ||
49 | #else | ||
50 | #set($discard=$xwiki.jsx.use("MoccaCalendar.MoccaCalendarEventSheet")) | ||
51 | #set($parentParamName="_parent") | ||
52 | #end | ||
53 | #end | ||
54 | {{/velocity}} | ||
55 | |||
56 | {{velocity}} | ||
57 | {{html wiki="true"}} | ||
58 | #set($eventClass = 'MoccaCalendar.MoccaCalendarEventClass') | ||
59 | #set($eventValidationDoc = 'MoccaCalendar.MoccaCalendarEventValidation') | ||
60 | #set ($discard = $doc.use($eventClass)) | ||
61 | ## add the groovy script to the validation (the xvalidation parameter in the request also works to set the groovy script validation) | ||
62 | #if($xcontext.action=='edit') | ||
63 | <input type="hidden" name="xvalidate" value="1" /> | ||
64 | <input type="hidden" name="xvalidation" value="$eventValidationDoc" /> | ||
65 | ## the following values must be added explicitly in "plain edit view", as used by the modal popup | ||
66 | ## because the "plain view" does not give them to us | ||
67 | #if($request.xpage=='plain') | ||
68 | <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> | ||
69 | <input type="hidden" name="language" value="$!{escapetool.xml($tdoc.realLanguage)}" /> | ||
70 | #end | ||
71 | #end | ||
72 | (% class="xform" %) | ||
73 | ((( | ||
74 | #if($xcontext.action=='view' && $calendar) | ||
75 | ; <label for="calendar">$escapetool.xml($services.localization.render('MoccaCalendar.calendar'))</label> | ||
76 | : [[$calendarDoc.getDisplayTitle()>>$calendarDoc.fullName]] | ||
77 | #elseif($xcontext.action=='edit') | ||
78 | #set($hql =", BaseObject as obj where doc.fullName=obj.name and doc.name!='MoccaCalendarTemplate' and obj.className='MoccaCalendar.MoccaCalendarClass' order by doc.title, doc.name") | ||
79 | ; <label for="calendar">$escapetool.xml($services.localization.render('MoccaCalendar.calendar'))</label> | ||
80 | : <select id="calendarParent" name="$parentParamName"> | ||
81 | #foreach($item in $services.query.hql($hql).execute()) | ||
82 | #set($itemdoc = $xwiki.getDocument($item)) | ||
83 | #if($!{itemdoc} && ${itemdoc.hasAccessLevel("edit")}) | ||
84 | #set($selected="") | ||
85 | #if($itemdoc.getId() == $calendarDoc.getId()) | ||
86 | #set($selected=" selected='selected'") | ||
87 | #end | ||
88 | <option value="$escapetool.html($itemdoc.getFullName())"$selected>$itemdoc.getDisplayTitle()</option> | ||
89 | #end | ||
90 | #end | ||
91 | </select> | ||
92 | #end | ||
93 | ; <label for="MoccaCalendarEvent.MoccaCalendarEventClass_0_title">$escapetool.xml($doc.displayPrettyName('title', false, false))<span class="xRequired"></span></label> | ||
94 | : #if($xcontext.action=='edit')<input id="MoccaCalendarEvent.MoccaCalendarEventClass_0_title" type="text" name="title" value="$!{escapetool.xml($doc.getTitle())}" class="required" /> #showvalidationmessage("val_title_already_exists") <span class="val_title_notempty xErrorMsg" style="display:none;">$escapetool.xml($services.localization.render('val_title_notempty'))</span> <span class="val_title_notvalid xErrorMsg" style="display:none;">$escapetool.xml($services.localization.render('val_title_notvalid'))</span> | ||
95 | #else $doc.getDisplayTitle() | ||
96 | #end | ||
97 | ; <label for="MoccaCalendarEvent.MoccaCalendarEventClass_0_startDate">$escapetool.xml($doc.displayPrettyName('startDate', false, false))<span class="xRequired"></span></label> | ||
98 | : #displayDate('startDate') | ||
99 | ; <label for="MoccaCalendarEvent.MoccaCalendarEventClass_0_endDate">$escapetool.xml($doc.displayPrettyName('endDate', false, false))</label> | ||
100 | : #displayDate('endDate')#showvalidationmessage("val_endDate") | ||
101 | |||
102 | ; <label for="MoccaCalendarEvent.MoccaCalendarEventClass_0_allDay">$escapetool.xml($doc.displayPrettyName('allDay', false, false))</label> | ||
103 | : $doc.display('allDay') | ||
104 | ; <label for="MoccaCalendarEvent.MoccaCalendarEventClass_0_description">$escapetool.xml($doc.displayPrettyName('description', false, false))</label> | ||
105 | : $doc.display('description') | ||
106 | ))) | ||
107 | #if($!{request.xpage}!="plain") | ||
108 | ---- | ||
109 | |||
110 | #if($xcontext.action=='view') | ||
111 | #if($backToCalendarDoc) | ||
112 | [[$services.localization.render('MoccaCalendar.calendarevent.backlink', [ $backToCalendarDoc.getDisplayTitle()])>>$backToCalendarDoc]] | ||
113 | #end | ||
114 | #end | ||
115 | #end | ||
116 | {{/html}} | ||
117 | ## please do not add linebreaks here, or the "save"-button will jump if there are validation errors | ||
118 | #if(($xcontext.validationStatus.errors&&$xcontext.validationStatus.errors.size()>0))$response.setStatus(400)#end | ||
119 | {{/velocity}} |