[xwiki-users] Mocca calendar - display 'short description' instead of title in month/week/day view
In our use of the calendar extension, I expect to have situations where the title is repeated (sometimes for what are really recurring events and sometimes not). For this reason, we'll leave the randomly generated string in the title field. I've added a 'short description' field to the event class to use in place of the title. I would like to display the new field in the calendar month/week/day view instead of the title. Does anyone have suggestions on how to do this? I'm using XWiki 7.4. -- View this message in context: http://xwiki.475771.n2.nabble.com/Mocca-calendar-display-short-description-i... Sent from the XWiki- Users mailing list archive at Nabble.com.
Hi Mark,
In our use of the calendar extension, I expect to have situations where the title is repeated (sometimes for what are really recurring events and sometimes not). For this reason, we'll leave the randomly generated string in the title field.
To start with, there is probably a bug here. The document where the event is stored should have a name (which indeed has to be unique per calendar, but should only show up in the URL if viewing the "detailed view" of that event) and a title - which is also displayed in the overview. There should be a random generated component of the name, but this should not show up in the document title; this field should initially be empty when creating a new event. This looks very much like the following bug: http://jira.xwiki.org/browse/MOCCACAL-68 I cannot reproduce this with the current version (XWiki 7.4, MoccaCal 2.5). Which version of the Mocca Calendar are you using? (This should be shown in the Wiki Admin, section "Installed Extensions")
I've added a 'short description' field to the event class to use in place of the title. I would like to display the new field in the calendar month/week/day view instead of the title. Does anyone have suggestions on how to do this?
I'm using XWiki 7.4.
Fetching the data which is displayed in the actual calendar happens in the page MoccaCalendar.JSONService (You can find this page at /xwiki/bin/view/MoccaCalendar/JSONService ) If you edit it in the Wiki-editor you will see it contains ... quite some code handling the creation of unique document names, and the query to fetch all events that should be shown to the current calendar display. It is the second part that you will want to adapt. Scroll down and search for something like: #set($event = {"id" : $itemdoc.getDocumentReference().toString(), "title" : $itemdoc.getPlainTitle(), ... here the "title" is filled in as the document title. If you want to get a field from the event, then this data is available as: $itemdoc.getValue('short_description') (or whatever the name of the field is), so you can replace the $itemdoc.getPlainTitle() with that String. This covers the "normal" calendar view. The "Agenda"-style view with the upcoming events is handled differently unfortunately; here the JSON-Service this returns fully rendered HTML to be inserted into the page directly, and you need to chnage this part, too. You can search for a " ... + $escapetool.html($itemdoc.getPlainTitle()) + ... " - that is the place where you want to add / insert your custom field, hope this helps, Clemens
Clemens, Your suggestion gets me part of the way there but still having some problems (in steps 11 and 12 below). I thought maybe my earlier futzing around trying to get it working on my own screwed things up. So I created a clean instance on a VM and made the mods you suggested. Here are the steps I followed and the results. 1. Created new XWiki 7.4 instance - distribution wizard doesn't start for some reason so I installed the default pages using xwiki-enterprise-ui-mainwiki-all-7.4.xar. 2. Installed MoccaCalendar extension and verified that version is 2.5 (full calendar macro is version 2.0.2) 3. Logged in as Admin and created a new calendar (first to verify behaviour without your suggested mods to JSON Service). 4. In the new calendar created an event - event is displayed as expected. 5. In the new calendar, tried to create another event with the same title - event form displays 'An event with this name already exists.' under the title field. 6. In the new calendar, tried to create another event with no title - event form displays 'Title field is required'. 7. Deleted event created in step 4. 8. In class editor MoccaCalendarEvent class added new field 'Test' of type String. 9. Navigated to /xwiki/bin/view/MoccaCalendar/JSONService -> Edit -> Source and replaced $itemdoc.getPlainTitle() with $itemdoc.getValue('Test') in two places as you suggested. 10. Returned to new calendar created in Step 3. 11. Invoked form to create an event - event form is displayed with new Test field (blank). But the Title field is populated with a random string and the Calendar drop down field where you can select which calendar the event belongs to is missing from the form. 12. Entered a value in the Test field and saved the event - the form disappears but the event is not displayed on the new calendar. 13. Navigated to Calendar Overview and observed that new event is displayed there with the content of the Test field instead of the Title. Here the event is displayed on the Month view the way I want it. -- View this message in context: http://xwiki.475771.n2.nabble.com/Mocca-calendar-display-short-description-i... Sent from the XWiki- Users mailing list archive at Nabble.com.
Hi Mark, Thanks for the detailed problem report. I can confirm your results from step 1 to step 5. This is indeed a bug that needs fixing; I have added it as http://jira.xwiki.org/browse/MOCCACAL-91 Then I tried to follow the steps from 8 but could not reproduce the issue described in step 11 Just adding a new field should not make this field show up in the event creation form automatically. Did you do anything else like editing the MoccaCalendarEventSheet, or reset this to a default state? This might have scrapped the code for the somewhat non-trivial title handling necessary to avoid http://jira.xwiki.org/browse/MOCCACAL-68 It might also explain why there is no drop down to pick the calendar for the event; the new event is then created without "parent calendar" and this only visible in the main "show all events" overview, as you figured out in step 13. The "calendar" drop down in the edit view is also some custom code that will be absent if the MoccaCalendarEventSheet is overwritten. I am not aware that there is a mechanism that causes XWiki to "auto-update" the class sheet, unless one edits the class with "App Within Minutes" ... which I thought is not possible MoccaCalendar classes, but maybe I am overlooking something. If you recover the MoccaCalendarEventSheet by rolling back to an earlier version via its history and add a line like ; <label for="MoccaCalendarEvent.MoccaCalendarEventClass_0_test">$escapetool.xml($doc.displayPrettyName('test', false, false))</label> : $doc.display('test') in the place where all these other fields are rendered with code like that, the problem in step 11 with 13 should go away. I am afraid that then the bug from step 1 to step 5 will be fully restored, however. As a work around you can change the: <input type="text" name="title" value="$!{escapetool.xml($doc.getTitle())}" class="required" /> into: <input type="hidden" name="title" value="$!{escapetool.xml($doc.getDisplayTitle())}" /> this however will fill the title field with a random string and might make migration to a bug-fixed version later problematic, unless you are happy to stick with your custom modification. If you can wait one day or two I would prefer to fix the issue so you can upgrade and use events with a proper title. Anyway, thanks a lot for the detailed steps to reproduce the problem. This is indeed a serious bug and I will try to fix it as soon as possible. Cheers Clemens
Clemens, Your suggestion gets me part of the way there but still having some problems (in steps 11 and 12 below). I thought maybe my earlier futzing around trying to get it working on my own screwed things up. So I created a clean instance on a VM and made the mods you suggested. Here are the steps I followed and the results.
1. Created new XWiki 7.4 instance - distribution wizard doesn't start for some reason so I installed the default pages using xwiki-enterprise-ui-mainwiki-all-7.4.xar. 2. Installed MoccaCalendar extension and verified that version is 2.5 (full calendar macro is version 2.0.2) 3. Logged in as Admin and created a new calendar (first to verify behaviour without your suggested mods to JSON Service). 4. In the new calendar created an event - event is displayed as expected. 5. In the new calendar, tried to create another event with the same title - event form displays 'An event with this name already exists.' under the title field. 6. In the new calendar, tried to create another event with no title - event form displays 'Title field is required'. 7. Deleted event created in step 4. 8. In class editor MoccaCalendarEvent class added new field 'Test' of type String. 9. Navigated to /xwiki/bin/view/MoccaCalendar/JSONService -> Edit -> Source and replaced $itemdoc.getPlainTitle() with $itemdoc.getValue('Test') in two places as you suggested. 10. Returned to new calendar created in Step 3. 11. Invoked form to create an event - event form is displayed with new Test field (blank). But the Title field is populated with a random string and the Calendar drop down field where you can select which calendar the event belongs to is missing from the form. 12. Entered a value in the Test field and saved the event - the form disappears but the event is not displayed on the new calendar. 13. Navigated to Calendar Overview and observed that new event is displayed there with the content of the Test field instead of the Title. Here the event is displayed on the Month view the way I want it.
-- View this message in context: http://xwiki.475771.n2.nabble.com/Mocca-calendar-display-short-description-i... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
mit freundlichen Grüßen Clemens Klein-Robbenhaar -- Clemens Klein-Robbenhaar Software Development EsPresto AG Breite Str. 30-31 10178 Berlin/Germany Tel: +49.(0)30.90 226.763 Fax: +49.(0)30.90 226.760 [email protected] www.espresto.de HRB 77554 B - Berlin-Charlottenburg Vorstand: Maya Biersack, Peter Biersack Vorsitzender des Aufsichtsrats: Dipl.-Wirtsch.-Ing. Winfried Weber Zertifiziert nach ISO 9001:2008
Small Update: Release 2.5.1 is out now, fixing that issue:
I can confirm your results from step 1 to step 5. This is indeed a bug that needs fixing; I have added it as http://jira.xwiki.org/browse/MOCCACAL-91
[...]
1. Created new XWiki 7.4 instance - distribution wizard doesn't start for some reason so I installed the default pages using xwiki-enterprise-ui-mainwiki-all-7.4.xar. 2. Installed MoccaCalendar extension and verified that version is 2.5 (full calendar macro is version 2.0.2) 3. Logged in as Admin and created a new calendar (first to verify behaviour without your suggested mods to JSON Service). 4. In the new calendar created an event - event is displayed as expected. 5. In the new calendar, tried to create another event with the same title - event form displays 'An event with this name already exists.' under the title field. 6. In the new calendar, tried to create another event with no title - event form displays 'Title field is required'. 7. Deleted event created in step 4. 8. In class editor MoccaCalendarEvent class added new field 'Test' of type String. 9. Navigated to /xwiki/bin/view/MoccaCalendar/JSONService -> Edit -> Source and replaced $itemdoc.getPlainTitle() with $itemdoc.getValue('Test') in two places as you suggested. 10. Returned to new calendar created in Step 3. 11. Invoked form to create an event - event form is displayed with new Test field (blank). But the Title field is populated with a random string and the Calendar drop down field where you can select which calendar the event belongs to is missing from the form. 12. Entered a value in the Test field and saved the event - the form disappears but the event is not displayed on the new calendar. 13. Navigated to Calendar Overview and observed that new event is displayed there with the content of the Test field instead of the Title. Here the event is displayed on the Month view the way I want it.
[...]
You're right - I missed a step. After step 8 I edited the event class with the wiki editor. The Test field appeared on the form in the editor without me having to do anything explicitly. I selected Save&View with the Update Class Template, Update Class Sheet, and Update Class Translation Bundle options checked. And running through the steps again, I confirmed that the Test field does not appear on the form before I do the wiki edit. -- View this message in context: http://xwiki.475771.n2.nabble.com/Mocca-calendar-display-short-description-i... Sent from the XWiki- Users mailing list archive at Nabble.com.
Ah, there is the "App within minutes" editor coming in"! Actually it is a leftover from the time when this extension has been bootstrapped from "App Within Minutes". I guess I better scrap this because the "automatically created edit form" is not really useful in this case, as you have figured out Clemens
You're right - I missed a step. After step 8 I edited the event class with the wiki editor. The Test field appeared on the form in the editor without me having to do anything explicitly. I selected Save&View with the Update Class Template, Update Class Sheet, and Update Class Translation Bundle options checked.
And running through the steps again, I confirmed that the Test field does not appear on the form before I do the wiki edit.
-- View this message in context: http://xwiki.475771.n2.nabble.com/Mocca-calendar-display-short-description-i... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (2)
-
Clemens Klein-Robbenhaar -
Mark Sack