Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Layout rules: a warning prototype (Read 2402 times)
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Layout rules: a warning prototype
Aug 15th, 2011, 4:44am
 
Here's an elegant little trick that fellow user Ted Goranson has kindly let me share here.  Elsewhere I'm helping him with a fairly complex TBX. The complexity means that in order to avoid unexpected consequences of rules, exports, etc., it is necessary to apply some 'business rules'. Call the latter whatever you like, but they are rules we need to apply, but people are forgetful. Ted came up with the following neat prototype-based trick which can easily be adapted to your own project, if pertinent.

In the original scenario, we have notes (p_note) that set and can have multiple subnotes (p_subnote). The former prototype's $OnAdd sets the prototype for its children, automatating soe aspects of visualisation. Here I've coloured the two note types for clarity:



Now let's get forgetful that subnotes don't have children and add a subnote to "Another-subtopic". See what happens:



But, perhaps you're a fast touch-typist you type the title and opened the note to add $Text without even looking at the main view. If so, you see this:



Either/both of those things should make you realise you need to back up. The warning sits out of the way and just butts in as appropriate -here it only affects adding a child to a note based on "p_subnote".

Of course, you can use a different trigger. It doesn't need to be $OnAdd based. However, in the the latter case the 'rule' will be implemented less immediately so things like default $Text might not get seen because you'd added $text before p_warning is set.

So, how do you make your own prototype like this?  These are some of the things I see for the above demo:
  • The $OnAdd in "p_subnote" is: $Prototype = "p_warning";. This is your 'business rule' that decides when a warning is shown. As stated above, you can set some different trigger.
  • The rest of the bullets apply to p_warning itself:
    • $IsPrototype. Set to true, of course!
    • $Badge. Here I've set the built-in badge 'x'. You could even supply your own custom badge. Bear in mind that your choice of TB layout may mean you need something with more/less contrast.
    • $NameBold. Makes the note title stand out in main views.
    • $Color. I used "bright red". You may chose not to colour or use something more fitting your colour palette.
    • $DisplayExpressionDisabled. Set to true (Boolean). This is why the prototype doesn't show its $DisplayExpression.
    • $DisplayExpression. "A child note is not allowed here". Or, put whatever warning is appropriate for your project.
    • Text customisation. In this scenario we expect the user to throw away this note so it doesn't matter how we customise the text. If however, you might actually want to remove the warning prototype and move the note elsewhere, I'd suggest leaving text settings as default.
  • ..and so on.  You can make more/different/fewer settings as suit your style.
Closing thoughts. Before someone asks "But when must I...", there is no requirement on users to employ the technique above.  Rather, some users - by attitude or project needs, may find it useful. Also, like any prototype, p_warning (or whatever you call it) can sit anywhere in your TBX - it doesn't have to be in a discrete container though the latter is sensible approach.

Lastly, in a general overall context the above also shows how prototypes can affect note visualisation. I hope this is of use and thanks to Ted for letting me share his idea.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print