Use Custom Event Properties for Canvas Decision Splits in Braze? - appboy

Problem: Is it possible to use custom event properties (triggering a canvas) inside the canvas, e.g. for decision splits?
Example: Fire a custom event A into braze, containing a custom attribute "status = {X, Y}". Create an action-based campaign w/ trigger action "Perform Custom Event A". Inside the canvas, add a decision split step that separates incoming user into Path 1 (status == X) and Path 2 (status == Y), with "status" being the custom attribute from above.
Looking at the Braze UI and documentation this seems not to be possible. However, for message content customisation using liquid these custom attributes seem to be available: {{canvas_entry_properties.${product_name}}}

Related

some documentation about _onchange_spec() methose in odoo

in chapter 6 of the book Odoo Development Cookbook the author introduces the _onchange_spec () methode and he presented it as a follow :
This method will retrieve the updates that are triggered by the odification of which other field. It does this by examining the form view of the model (remember, onchange methods are normally called by the web client).
i need more details
Welcome to the stackoverflow community.
The main objective of the _onchange_spec () method is to call the onchange method from the server side.
In the example of the book you mention, it is explained that:
you can do the required computation yourself, but this is not always
possible as the onchange method can be added or modified by a
third-party addon module installed on the instance that you don 't
know about.
When called:
Passing no argument. This method will retrieve the updates that are triggered by the modification of which other field. It does this by examining the form view of the model.
How to Use it:
You must use it when you want to manually run an onchange method and compute something before creating the registry or updating it.
Example
#api.multi
def return_all_books(self):
self.ensure_one
wizard = self.env['library.returns.wizard']
#this is the manual change (update the member)
values = {'member_id': self.id}
#this examines the form to find the changes
specs = wizard._onchange_spec()
#This gets the values of the onchange
updates = wizard.onchange(values, ['member_id'], specs)
#Combine the results with the new manually added value
values.update(updates.get('value', {}))
record = wizard.create(values)
For another implementation you can check below.
you can see a implementation for testing here

Intents with extras have a series of params that we don't use - what's their purpose?

From my LandingClass (which contains a ListView called myList), whenever an item from the ListView is clicked, we want to trigger another activity (DetailedActivity), so the code should look like this:
myList.setOnItemClickListener{ view ->
val intent = Intent(this, DetailedActivity::class.java)
startActivity(intent)
}
Now, if we needed to provide additional (extra) info to the Detailed class, such as the position of the element from the ListView that we just clicked, the code would look like this:
myList.setOnItemClickListener{ parent, view, position, id ->
val intent = Intent(this, DetailedActivity::class.java)
intent.putExtra("thePosition (text)", position)
startActivity(intent)
}
So my question is why in case of sending the extra intent, we need a parent and an id, I don't see them being used anywhere... ?
I don't see some examples in the doc to help me understand. So some questions:
What do I need the parent, view and id for?
If I click the 3rd element, the position (int) sent I expect to be 2 if the list is 0-index based, right?
If I wanted to send a Bundle with more complex information than the position, how would my code (with extra) change? Considering that all params have a defined type, like id is type long. WHat if I wanted to send a paragraph of text instead of the id?
https://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener - the official docs showing the method signature
From my research (see above link) I noticed that:
parent AdapterView: The AdapterView where the click happened.
Why would we need this? Where is the assignment done, or is it implicitly known?
view View: The view within the AdapterView that was clicked (this will be a view provided by the adapter)
position int: The position of the view in the adapter.
id long: The row id of the item that was clicked.
Still this doesn't clarify how to send additional complex info to the DetailedActivity - not a position (int) or an id (long) but maybe an array of complex objects, or a paragraph of text or something else...
Say that your ListView contains the headers of some news articles.
By clicking on a list item you want to be redirected to a details activity where you can read the full text of the article.
All headers and articles are stored in a List of Article objects, each containing the header and the text of the article.
How will you identify which article's header was clicked?
This is the purpose of the arguments position and id.
Depending on your needs you will choose one or the other, so you will fetch from the List the article's text and pass it as an extra to the Intent that opens the details activity.
You know that you can create very complex ListViews where each item is a container of multiple views or a ListView itself.
This is when you will need the parent and view arguments.
All this is application specific.
If you don't need it fine, but the arguments are there for you to use if and when you will need them.
Now for:
If I wanted to send a Bundle with more complex information
and
Still this doesn't clarify how to send additional complex info to the
DetailedActivity
This is your responsibility to construct a Serializable or Parcelable Bundle and put it as an extra to the Intent and has nothing to do with the available arguments of setOnItemClickListener. There are a lot of examples here in SO and other sites for serializing objects to put as extras, like
Cannot pass custom Object in an Intent: The Method Put Extra is Ambiguous for the type Intent
and
How to send an object from one Android Activity to another using Intents?
Follow the standards and you will be able to send this complex info via intent.

Aurelia Validation rule (bound to model) does not fire on subsequent activations of a view model

I am trying to expand on the Aurelia Contact Manager Tutorial. Specifically: adding email validation to the contact-details.html view. I have followed the examples in the Validation: Basics documentation and on first pass it worked as expected: Launch application, select a contact from the contact-list module, then update the email to something invalid by removing the '#', then tab away. The validation rule fires and the error message is displayed.
However, if after launching the application I select a first contact followed by a second, hence triggering a second activation of the contact-details module, then the validation rule does not fire.
I have tried a validationController.reset() on activate of the contact-detail and while this will remove any 'old' error messages, the on blur validation will still not fire.
I have tried the two different methods of creating the validation controller (using NewInstance.of(ValidationController) vs ValidationControllerFactory) but both yield the same result.
If, after navigating to a second contact and 'breaking' the validation, I then refresh the browser and reload the page then the validation works again. Until I choose another contact from the list which will then break it again.
I am new to Aurelia and JavaScript frameworks in general and I'm not sure if this is a bug or there is something extra required to handle re-routing to the same page.
That's a good question. There are a couple of things that may be catching you out. I've created a Gist which includes the necessary file modifications to get this working:
https://gist.github.com/freshcutdevelopment/170c2386f243e7095e276811dab52299
Gotchas
Because the view-model you're using for validation is not the backing view-model for the contact-detail.html view file you'll need a separate class which you'll apply the validation rules to. Although it sounds like you've already nailed this part, I'll include it for completeness. You can create this class like so:
export class Contact {
email= '';
}
You can then apply the validation rules to this class as follows:
ValidationRules
.ensure(a => a.email).required().email()
.on(Contact);
The last possible missing puzzle piece here is that you'll need to hook into the screen activation life-cycle hook deactivate() and reset the validation context. This will force the BootstrapValidationRenderer to remove the validation styles from your view.
deactivate(){
this.controller.reset();
}
Validation Workflow
The steps are as follows:
Inject the controller
Add the validation renderer to the controller
Create the validation model (only needed if the model you want to validate is not the view-model that backs your view)
Apply the validation rules to the model
Determine when to re-set and execute the validation (in this case on the deactivate life-cycle hook.
Apply the validation binding behavior to the view

making a picture slider in elm, model updates triggered by loaded element

I am making a website in elm that includes a dynamic element for browsing pictures. One can click a given thumb to see the full picture in a lightbox, navigate to the next or previous picture or let the picture change automatically every three second.
By default one sees only a small selection (4 thumbs) but it is possible to previews all the thumbs by clicking on "voir toute les photos"
running example here
Each user click or tick of the clock change the underlying model, which in turn makes the browser actualize the HTML accordingly.
I am mostly satisfied with the current level of functionality except for the fact than I can't find a way to display a transition screen (or picture) while the next picture is loading.
The lightbox displays the last displayed picture while loading the next one, and transitions abruptly.
Is there a way to trigger a change in the model only when the next picture is loaded?
Or a more idiomatic way to do this sort of thing? I am quite new to elm and web development in general.
the elm code for the gallery is visible at:
https://github.com/eniac314/mairieMurol/blob/master/src/Gallery.elm
It sounds like you just need a way to know when an image is finally loaded. You can tie into the img.onload DOM event, but first you'll need a Json Decoder to pull image src attribute out of an event.
Updated to elm-0.18
onLoadSrc : (String -> msg) -> Html.Attribute msg
onLoadSrc tagger =
on "load" (JD.map tagger targetSrc)
targetSrc : JD.Decoder String
targetSrc =
JD.at [ "target", "src" ] JD.string
Now you can use that decoder to call a new ImageLoaded String action, passing the image source as a string.
img
[ src imgsrc
, onLoadSrc ImageLoaded
]
[]
Look at demo and code (you may need to change the random number in the image url to combat the browser caching the image).

ASP.NET MVC Set texts in the View or in the Controller

What is the best practice in MVC (for testing, SOC and scaffolding) for setting texts (for exemple page title, h1,h2..)
Is it better to do it in the controlle, fill a viewmodel and send it to the view
or directly typing texts in the view?
Also I will propably use ressouces files for global texts (like button text, menu texts) and local ressouces for view specific texts.
The view is merely to present the output to the user. Depending on your requirement you can either:
1) Type the text in the view directly <h2>Hello World</h2> (for static content that will not change)
The latter two options are for ideal for dynamic content, where the content could be received from a database or some additional input.
2) Use the ViewBag to pass information to the view (in which case you would set it in the controller ie. ViewBag.HelloWorld = "Hello World" : <h2>#ViewBag.HelloWorld</h2>
3) Use a model to pass the information to your view. This should be your preferred option where possible. In your specific case you could use the controller to retrieve the content from your global resources, bind it to the model and pass it to the view.
The logic on where to get the data should come from the controller and the View's function should be to merely display it.
I recommend binding properties on the viewModel to the UI.
This is not only more testable, but it's also more flexible. It makes it easier to implement features like mult language support etc.
I recommend avoiding hard coding text in the markup if you can