RenderTopicInstaller
Render a simple factory to deploy a topic in another web

02 May 2019 - 19:27 | Version 1 |

Documentation

This is a tool to add a topic based application, or part of it to another web. This is done by creating a TopicStub that points back to the implementation. For example, to add a new TopicType to web, you create a TopicStub that points back to the implementation of that TopicType.

The function will display a small input form to specify the web where the TopicStub is to be created.

Parameters
  • TEXT: headline for the install form, defaults to "Install BASETOPIC"
  • NAME: name of the topic to be created, defaults to BASETOPIC
  • SOURCE: used to specify the TopicStub's target to be created, defaults to BASEWEB.BASETOPIC
  • PARENT: topicparent of the new topic, defaults to HOMETOPIC
  • TEMPLATE: TopicTemplate used to create this topic, defaults to TopicStubTemplate
  • FORM: DataForm used for this topic, defaults to TopicStub
  • TYPE: type of the new topic, defaults to TopicStub
  • WIKIAPP: the name of the WikiApllication this topic belongs to, defaults to BASEWEB
  • EXTRA: extra stuff to be send during save

Implementation

%STARTINCLUDE%
%TWISTY{
  mode="div"
  link="%BUTTON{"%TRANSLATE{"Install"}%" icon="application_add"}%%CLEAR%"
}%

<form id="topicinstaller" action="%SCRIPTURLPATH{"save"}%/" method="post">
<div class="foswikiFormSteps">
<h2 >%TEXT{default="%TRANSLATE{"Install %BASETOPIC%"}%"}%</h2>
<input type="hidden" name="onlynewtopic" value="on" />
<input type="hidden" name="TopicTitle" value="%FORMFIELD{"TopicTitle" topic="%SOURCE{default="%BASEWEB%.%BASETOPIC%"}%"}%" />
<input type="hidden" name="Summary" value="%FORMFIELD{"Summary" topic="%SOURCE{default="%BASEWEB%.%BASETOPIC%"}%"}%" />
<input type="hidden" name="topicparent" value="%PARENT{default="%HOMETOPIC%"}%" />
<input type="hidden" name="templatetopic" value="%TEMPLATE{default="Applications.TopicStubTemplate"}%" />
<input type="hidden" name="formtemplate" value="%FORM{default="Applications.TopicStub"}%" />
<input type="hidden" name="TopicType" value="%IF{"defined TYPE" then="TopicStub, %TYPE%"  else="TopicStub"}%" />
<input type="hidden" name="Target" value="%SOURCE{default="%BASEWEB%.%BASETOPIC%"}%" />
<input type="hidden" name="WikiApplication" value="%WIKIAPP{default="%FLEXWEBLIST{include="%BASEWEB%" format="$name"}%"}%" />
%EXTRA{default="<!-- -->"}%
<input type="hidden" name="topic" id="topic" value="%NAME{default="%BASETOPIC%"}%" />
<div class="foswikiFormStep">
  <h3>Target web:</h3>
  <select id="newweb" name="web" class="jqSelect2" data-width="30em"> 
    <option></option>
    %FLEXWEBLIST{
      format="<option value='$web'>$web</option>"
      webs="public,webtemplate" 
      separator=" " 
      exclude="Trash|Applications"
    }%
  </select>
  <div class="foswikiFormDescription">
    %TRANSLATE{"Select a web where to deploy this component."}%
  </div>
</div>
<div class="foswikiFormStep">
%BUTTON{"%TRANSLATE{"Submit"}%" icon="tick" type="save"}%
%CLEAR%
</div>
</div>
</form> 
%ENDTWISTY%
%JQREQUIRE{"select2"}%%ADDTOZONE{"script" id="TOPICINSTALLER" topic="%WEB%.%TOPIC%" section="init" requires="JQUERYPLUGIN"}%
%STOPINCLUDE%

JavaScript initialisation

%STARTSECTION{"init"}%<script>
jQuery(function($) {
  $('#topicinstaller').on('submit', function() {
    var $form = $("#topicinstaller"),
        $topic = $form.find('[name=topic]'),
        $web = $form.find('[name=web]');
    $topic.val($web.val()+'.'+$topic.val());
  });
});
</script>%ENDSECTION{"init"}%

Test

Install RenderTopicInstaller

Target web:

Select a web where to deploy this component.

Calls to 'RenderTopicInstaller'

Copyright

© 2006-2015 Michael Daum http://michaeldaumconsulting.com

This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. For more details read the LICENSE.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding AustLII Communities? Send feedback
This website is using cookies. More info. That's Fine