now also documented on the website, see
http://isis.apache.org/more-advanced-topics/How-to-suppress-contributions.html
.

On 5 December 2014 at 14:09, Dan Haywood <[email protected]>
wrote:

> Bit of a delay on this, but anyway... the good news is that it IS possible
> to suppress a contributed action on one parameter but not another.
>
> I've updated the kitchen sink app [1] to show how
>
> In the "contrib" package there are three entities:
> * Person  [2]
> * Preference  [3]
> * FoodStuff  [4]
>
> eg Mary LIKEs Apple, Mungo HATEs Banana, Midge LOVEs Oranges
>
> Neither Person nor FoodStuff knows about Preferences; the Preference is
> the tuple that associates the two together.
>
> The PreferenceContributions [5] service provides:
> * "likes" - contributed collection to Person
> * "firstLove" - contributed property to Person
> * "addPreference" - contributed action to both Person and FoodStuff
> - "removePreference" - contributed action to both Person and FoodStuff
>
> However, although "addPreference" and "removePreference" *are* contributed
> to all parameter types, this can be hidden using the .layout.json file.  In
> FoodStuff,layout.json [6] we have:
>
>
>   "actions": {
>     ...
>     "removePreference": {
>       "actionLayout": {
>         "cssClass": "btn-warn",
>         "hidden": "EVERYWHERE"
>       }
>     }
>   }
>
> which means that the "removePreference" action cannot be seen when viewing
> a FoodStuff entity.
>
> I'll add this stuff to our website for future reference.
>
> Cheers
> Dan
>
>
> [1] https://github.com/isisaddons/isis-app-kitchensink
> [2]
> https://github.com/isisaddons/isis-app-kitchensink/blob/master/dom/src/main/java/org/isisaddons/app/kitchensink/dom/contrib/contributee/Person.java#L41-41
> [3]
> https://github.com/isisaddons/isis-app-kitchensink/blob/master/dom/src/main/java/org/isisaddons/app/kitchensink/dom/contrib/contributed/Preference.java#L42-42
> [4]
> https://github.com/isisaddons/isis-app-kitchensink/blob/master/dom/src/main/java/org/isisaddons/app/kitchensink/dom/contrib/contributee/FoodStuff.java#L41-41
> [5]
> https://github.com/isisaddons/isis-app-kitchensink/blob/master/dom/src/main/java/org/isisaddons/app/kitchensink/dom/contrib/contributed/PreferenceContributions.java#L31-31
> [6]
> https://github.com/isisaddons/isis-app-kitchensink/blob/master/dom/src/main/java/org/isisaddons/app/kitchensink/dom/contrib/contributee/FoodStuff.layout.json#L57-57
>
>
>
> https://github.com/isisaddons/isis-app-kitchensink/blob/master/dom/src/main/java/org/isisaddons/app/kitchensink/dom/contrib/contributed/PreferenceContributions.java#L62-62
>
> On 19 November 2014 at 15:27, Jeroen van der Wal <[email protected]>
> wrote:
>
>> As to your question if you prevent something being contributed on only one
>> of the parameter classes: In the metamodel there's no way to specify that
>> but you could try to hide the contribution in the layout.json file.
>>
>> something like
>>
>> "actions":{
>>    "yourAction": {
>>       "hidden":{}
>>    }
>> }
>>
>> or
>>
>> "actions":{
>>    "yourAction": {
>>       "hidden":{"where":"ALWAYS" }
>>    }
>> }
>>
>> Can you check if this works?
>>
>> On Wed, Nov 19, 2014 at 4:15 PM, Jeroen van der Wal <[email protected]>
>> wrote:
>>
>> > Hi Erik,
>> >
>> > You have to repeat the same parameters on the hideXxx method as the
>> method
>> > that you're trying to hide.
>> >
>> > HTH
>> >
>> > On Wed, Nov 19, 2014 at 4:09 PM, Erik de Hair <[email protected]> wrote:
>> >
>> >> Hi,
>> >>
>> >> The method in my entity class is as follows:
>> >>
>> >> public boolean hideAddPhoneNumbers(PortalCompany owningCompany,
>> >> AbstractArticle phoneNumberArticle,
>> >>             PhoneNumberGrid gridNumber, AbstractSelectableNumberElement
>> >> numberElement)
>> >>     {
>> >>         return true;
>> >>     }
>> >>
>> >> I also tried
>> >>
>> >> public boolean hideAddPhoneNumbers()
>> >> {
>> >>     return true;
>> >> }
>> >>
>> >> The signature of the method in the service is
>> >>
>> >> public FixedPhoneNumberSubscription addPhoneNumbers(PortalCompany
>> >> owningCompany,
>> >>             AbstractArticle phoneNumberArticle,
>> >>             PhoneNumberGrid gridNumber,
>> >>             AbstractSelectableNumberElement numberElement)
>> >>
>> >>
>> >> Erik
>> >>
>> >> <mailto:[email protected]>
>> >>
>> >> On 11/19/2014 03:37 PM, Martin Grigorov wrote:
>> >>
>> >>> Hi,
>> >>>
>> >>> On Wed, Nov 19, 2014 at 4:20 PM, Erik de Hair <[email protected]> wrote:
>> >>>
>> >>>  Hi Martin,
>> >>>>
>> >>>>   I think you need to add method hideXyz() as explained at
>> >>>>
>> >>>>> http://isis.apache.org/how-tos/how-to-02-030-How-to-hide-
>> >>>>> an-action.html
>> >>>>>
>> >>>>>  By adding a hide to the repository I can only hide it everywhere or
>> >>>> nowhere but I can't choose to pop up at certain entities only. At
>> >>>> least, I
>> >>>> don't know how to do that.
>> >>>>
>> >>>> When I add a hideXXX() to the entity where I want to hide the action,
>> >>>> Isis
>> >>>> complains about an orphaned method because the method doesn't exist
>> at
>> >>>> the
>> >>>> entity itself.
>> >>>>
>> >>>
>> >>> Please share the method's code. The log is misleading. Most probably
>> the
>> >>> method signature is not correct.
>> >>>
>> >>> it should be :
>> >>> - public
>> >>> - returning boolean
>> >>> - the name should be hide[TheCamelCasedActionName](the, same,
>> >>> parameters,
>> >>> as, the, action, method)
>> >>> - the impl should use all available information to decide whether to
>> >>> return
>> >>> true or false
>> >>>
>> >>>
>> >>>
>> >>>> Erik
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>
>> >
>>
>
>

Reply via email to