How can we filter the options of an entity select component in the app config? - shopware6

We have an app and we would like to configure it to send out emails. On app activation a mail template type and a default mail template are created. However in the configuration we would like to be able to select which mail template we should send out. Our config.xml looks contains the following:
<component name="sw-entity-single-select">
<name>customerMailTemplate</name>
<entity>mail_template</entity>
<label>Choose which mail template to be sent to customers on reservation</label>
<labelProperty>description</labelProperty>
<placeholder>Select mail template</placeholder>
</component>
Our question has 2 parts:
Given that not all mail templates have a description, is there a way how we can include Type + description as labels? similar to the mail templates overview in the admin settings.
We would like to filter this list to only show mail templates of a certain type. I see that this component takes a criteria object but we could only transfer strings from the xml file to the component. Would this be possible?
Having a plugin would allow us to create custom components and add them in the admin, but I don't see how we could do this from an app. If the above are not possible is there a way to create a custom vue component from an app?

Unfortunately neither of those things are possible with apps as of today.
The component has a slot to override the label but since you can't access the template directly with apps, you can only define a single property for the label.
While the component does take a criteria, the config.xml schema is not prepared to take and pass a criteria to the component.
If this is a must-have you could go the route of adding a custom module for you app. This is essentially just an iframe with a source to a page you're hosting. On that page you'd have to build a custom select dropdown. To feed the dropdown with data you request the admin api (with the credentials you received in the app registration process). That's also when you can make use of the criteria filters.
POST /api/search/mail-template
{
"associations": {
"mailTemplateType": []
},
"filters": [
{
"type": "equals",
"field": "mailTemplateType.technicalName",
"value": "order_confirmation_mail"
}
]
}
With the data you received from that endpoint you could then also freely set the labels as you like.
Once the user made a selection you can then either save the selection on your app server or send it back to the admin api, e.g. for storing it in the plugin config.
POST /api/_action/system-config
{
"MyApp.config.customerMailTemplate": "cc4996d68d22421081285fe957f85ec7"
}

Related

How to trigger specific action after event on all opened tabs in Nuxt.js

Imagine that we have a web application in which a user can log in.
After authorization, the user has access to his list of projects. When the page with projects is loaded, the client sends a request to the server and receives this list. When a new project is added, a second request is made to the server, and the list of projects is updated.
At this stage, everything is clear.
Now imagine that the user has opened a list of projects in several tabs in the browser at once. After changing the list on one open tab, a certain "trigger" should be triggered, which will force the remaining open components to perform certain actions.
More specifically.
We have the same link opened three times in different tabs: "Tab 1", "Tab 2", "Tab 3".
The user has created a new project on "Tab 1" and I need "Tab 2" and "Tab 3" to request new data from the server and update the list.
Please tell me how best to implement this. I tried using Vuex and it worked while there was no pagination in the application. Pagination does not allow storing all objects in one list, because different pages can be opened on different open tabs. Any ideas would be helpful. It may still be worth using a Vuex, but in a different way, or the solution lies elsewhere.
what about socket.io ? have you read about it ?
i think you could achive your desire performance with it
In this case the solution could be: use POST request in nuxt proxy server or in your backend, like axios.post('/data', payload) and connect the websockets, you can use pusher for that. The final logic is: user add some data => post to server => server emits the websockets event => vuex listen to the event and the data will be reactive in all tabs.

Mailjet Template API: Add attachments to template

I want to add inline images to my transactional email templates.
I can't find on the official API a way to push attachments for a template.
I've tested with the following parameters :
{
"ContentType": "image/png",
"Filename": "image.png",
"Base64Content": "base64code"
}
The API doesn't recognize the property : Properties not supported in JSON payload
I don't to attach my image each time I send the email using Send API.
Is there any way to attach files to a Mailjet Template.
Regards,
Clément
At the moment, it is not possible to insert an attachment in the template. Attachments should be provided in each transactional API call.

How see analytics about branch links created using mobile SDK

I am creating dynamic branch links using Android SDK
https://github.com/BranchMetrics/android-branch-deep-linking#creating-a-deep-link
These are then shared to social media
How do I track things like click events, installs etc as I do not believe they show up in the dashboard quick links view? https://dashboard.branch.io/quick-links
Is there a HTTP API I can use to interrogate all links I may have dynamically created that are part of the same campaign?
Alex from Branch.io here:
You are correct that SDK-generated links do not show up in the Quick Links view on the dashboard. Most SDK-created links are 'disposable' (in that they get used once and then regenerated the next time), so showing every link there individually would quickly overwhelm the UI. It is possible to override this on a link-by-link basis with the type parameter, as detailed here.
However, you can access the numbers in aggregate, segmented by campaign value, which I believe is what you want anyway. This is not currently available through the API, but you can see these statistics through the Sources report on the dashboard: https://dashboard.branch.io/sources
you must include a "type": 2 in your branch params
https://help.branch.io/developers-hub/docs/deep-linking-api
const branchConfig = {
"branch_key": environment.branchio.key_live,
"type": 2,
"data": {
"$marketing_title": (params.job_name ? params.job_name : ""),
}
};

Vue.js - Element UI - Upload file add a parameter

I'm using vue.js 2.3 and element-ui.
I'd like to use the upload-file component to send files to my server.
In the doc we can find the action "https://jsonplaceholder.typicode.com/posts/"
Question
I would like to know how can I add a parameter to the action?
Situation
I currently receive an array file with the data of my file but I would like to be able to pass other parameters
If you look at the list of attributes on the documentation page you linked to, there is a data attribute that lets you specify an object as "addition[al] options of [the] request".

How can I use vue.js and wordpress rest api to template a specific page?

Does anyone know how to expand this theme ( https://github.com/gilbitron/wp-rest-theme ) in order to theme specific pages? For example, I would like to create a page called "Menu" which has a unique navigation to click through to child pages Breakfast, Lunch, Dinner, etc without reload. I'm used to creating individual .php files to theme specific pages to my liking via page-{slug}.php - Is there an equivalent workflow using vue.js and wp rest api?
Instead of using page-menu.php to customize the /menu page, I would imagine I'd need to create something like a menu-page.vue file and add a custom method to specifically call that page in order to template it.
I can't find any examples of this process. Any help would be greatly appreciated.
What I did was add a field using Advanced Custom Fields that determined which template the page should use. I wrapped the display in a component called PageContent that looks like this:
<div :is="page.template"
:page="page"
v-if="!$loadingRouteData"
transition="fade"
transition-mode="out-in">
</div>
router:
'/:slug': {
component: PageContent,
name: 'Page'
}
So when someone navigates to that route, I fetch the page based on the slug param. The page variable then has a template attribute through ACF, which determines the component to display and defaults to a generic page:
if(pages[0].acf.template){
return pages[0].acf.template;
}
return 'page'
You need the WP JSON API plugin as well as the ACF plugin that adds ACF data to the json
My site uses this setup, happy to share more code if you have more questions.