PWA studio extend paymentmethods option from my own package without changing the Venia-ui source code - components

I would like to extend the CheckoutPage/PaymentInformation/paymentMethods.js component from my own package so that it can be used without having to manually change the source code from venia-ui.
I can change inside the component by intercepting to a target for my custom payment method like so
checkoutPagePaymentTypes.tap(payments =>
payments.add({
paymentCode: 'fairstone',
importPath:
'#magento/fairstone_pwa_venia_sample/src/components/fspaymentmethod.js'
})
);
But when I want to update the look of my payment method option before clicking into the component there isnt a target that i can hook into to extend the paymentMethods.js component.
I'm not super familiar with PWA-Studio and Venia-UI. How do i extend this parent component that doesn't have an object on the api to point a path to.

Related

Spartacus: Override cx-update-profile to add/modify input fields in PersonalDetails

Am trying to modify Personal details page in myaccount, i want to add new input fields, remove some existing input fields, how to achieve this, appreciate your help. Thanks.
General way of replacing a CMS component
find the flexType of the component, or the component typecode from the /pages request in your browser tools - network tab.
generate a module and a component with the ng-cli (ng g m your-profile-details followed by ng g c your-profile-details
configure your component to be used https://sap.github.io/spartacus-docs/customizing-cms-components/#page-title
copy the entire HTML from the OOTB source code
in the *component.ts file, you extend the OOTB component extends XXComponent
sometimes you have to copy the implementation as well, depending on the visibility of the attributes / functions in the OOTB component.
Run yarn run start and verify if your component is now in use!
Modify your component HTML to your liking.

how to override a shared component in spartacus storefront

I am trying to add more information to the price section in the cx-cart-item component:
cart entries
However, I don't see an outlet so that I can just attach the component "after" or "before" the price
How do I extend the render functionality? I am thinking:
copying and pasting the html and ts to just "append" the functionality - when I tried this I get errors indicating that tags such as cx-media does not exist
find a way to override the component, however, I think this is not possible since I was not able based on the documentation here https://sap.github.io/cloud-commerce-spartacus-storefront-docs/customizing-cms-components/#custom-angular-cms-components
The simplest answer, for now, would be overriding the component, as in the docs you've specified.
You can check the working example here:
https://github.com/tobi-or-not-tobi/spartacus-bootcamp/tree/master/src/app/features/components/banner
In the future, it should be possible to easily replace not only cms components, but also lower-level components.

extLib / appllicationLayout: how can I define link node to open a page in a new tab?

using extLib's applicationLayout control I'd like to place a link to a different application inside the bannerApplicationLinks node. This basically works fine using a basicLeafNode if it wasn't for the fact that the other application opens in the same browser tab. There apprently isn't any way to set the target for any kind of linking node control.
Before I go ahead and rebuild layout and navigator from scratch so that I can use standard link controls: does probably someone know some kind of well-kept secret how I could accomplish this task the simple way?
This limitation btw. applies to all types of link node elements available from extLib...
It doesn't look like this is easy to add. Unlike normal links, the basicLeafNode does not seem to have a target attribute. If it did, a theme would allow you to set the default value of the target to "_new".
If you want to try extending the basicLeafNode, the code for the component is in com.ibm.xsp.extlib.controls plugin, com.ibm.xsp.extlib.tree.complex.ComplexLeafTreeNode. You would need to add a target property and also expose it in the configuration files in com.ibm.xsp.extlib.config package (extlib-outline_en.properties, extlib-outline.xsp-config and raw-extlib-outline.xsp-config.
The link is written in the renderEntryItemContent method in com.ibm.xsp.extlib.renderkit.html_extended.outline.tree.HtmlTagsRenderer (bear in mind that this covers other link classes, not all of which will have a target attribute).
The best option you have is to use CSS (for targeting) and CSJS in the onLoad event to add the target attribute to the links. In the onLoad you select all links with a specific class (or all links inside a named element) and add the target "_blank" attribute.

How to use webpack to manually test react components?

I know we should use unit tests for our reactjs components. But what I also want, is some way to manually test our components in isolation. Because we are working on small sprints in which we must deliver some finished component before having the page that first uses that component. And I want to see that full component really working (i.e. test integration with css and sub-components).
So to start with, I would like to see that new component rendered in black page that doesn't require that component directly, but to take that component name/path from a query-string parameter. And then I plan to add to that page some generic component configuration (e.g. a textbox with json representing the props to pass to that component).
The first problem I'm facing now is about how to configure webpack, webpack-dev-middleware, or webpack-dev-server to be able to load a component passed by parameter.
Anyone know how to that? Or a better way to handle this?
I would try something like this:
Set up an entry point that uses require.context.
Invoke require within that context based on your querystring. You should have you React component now. Render that through React.
In order to generate the test controls I would include the meta within the component using JSON Schema. The form controls could be then generated using some form generator such as plexus-form or tcomb-form.

developing library controls for xpages

I' working on a library control for Xpages and need some help in creating.
I would create a control which reads a configuration file and creates controls in a table, controls like Editboxes, checkboxgroups and so on.
so and now to my questions:
could I initiate controls from the Exlib or must I implement them all by my self?
if I could use them from the Exlib could anyone explain me how?
I hope its clear what i mean if not please ask me for further informations.
When creating your own components, if you're closely replicating some behavior that is already in an extension library component, I highly recommend you extend that component and just add what's needed to accommodate your different functionality. This makes things much easier and you don't have to code around every little scenario that the component might be placed in.
But, if you are developing a component that is nothing like any of the extension library or core components then just ensure your component extends UIComponent or UIComponentBase. If going this route, you'll also need to create your own renderer which extends Renderer. This is what will build the on-screen representation of your component. Again, if there's already something in the core components or extension library components that closely mimics what you need then make your renderer extend that renderer. Also, don't forget to include the renderer definition in the faces-config file and the component definition in the xsp-config file or your component won't work.
As for initiating controls from the extlib.... I assume you mean can you inject them onto the page at runtime. If so the answer is absolutely yes. To add an input text field to the page where there is a container (i.e. panel, div, span, whatever) with an ID of "someContainer"
XspInputText input = new XspInputText();
input.setValue("someValue");
input.setId("someID");
UIComponent container = FacesContext.getCurrentInstance().getViewRoot().findComponent("someContainer");
container.getChildren().add(input);
To see the api for all of the core and extension library components take a look at the XPages Controls Documentation. For a more complete tutorial on creating your own components take a look at my blog for creating a custom component inside an nsf, the steps are pretty much the same for putting them into a library:
Part 1,
Part 2 and there is an example database in the Part 2 post.

Resources