AngularJS updating model's content from another model - angularjs

I've got two lists of models (posts and glossary items) that are each loaded via AJAX and displayed in their own views. Both have a title and some HTML content.
What I'd like to do in the post view is wrap every mention of one of the glossary item titles in a link to that item. So if I have "Orange" and "Apple" glossary items every mention of "orange" or "apple" in any of the post content will get turned into a link.
I'm not sure how to go about it since both lists are being loaded via AJAX and it doesn't know which will be there first. I'm new to Angular though so I was hoping someone could give me an idea of what direction to go in or what feature I should be looking at.

Check the highlighter here , check the source code and modify it so that it can add a blue color and anchor tag, with href = your link for that item.
Also make sure you apply highlighter only after loading both the ajax reqs.

Related

Angular.js: How to Append Hash Fragment after clicking element and making this shareable

Apologies for the somewhat basic question.
On an Angular single page application, I'm trying to create a fragment identifier after clicking on an element and changing its CSS display attribute from display:none to display:inline. For instance, I'd like the URL to originally be something like:
www.example.com/about/
...and then after the element is clicked and displayed, the URL changes to:
www.example.com/about/hello
or
www.example.com/about/#hello
...and upon sharing the new link, I'd like that clickable element to automatically be set to display: inline.
I'm using ui-router. Would something like this be achievable with nested views? Or ui-sref? I'm not too sure what I should be researching or what direction to go in for this. Thanks in advance.

How can you attach a content item as an element field of another content item via its authoring template?

Let's say I defined a IBM WCM authoring template called "AT-Image"; it creates content item "CT-Image" that contains elements such as an Image of type "Image", Description of type "Short Text", Keywords of type "Text", and other fields that serve as meta for that image resource.
Now, I need to create a content item called "CT-Article" based off from its "AT-Article" authoring template. Let's say that "Article" item has 3 elements: Title, Summary, and Image. Title and Summary are of type "Short Text". But Image needs to be of type "CT-Image" and not Image or Image component.
Is this possible Out-of-the-Box or is this something I need to implement myself via WCM API?
From my point of view you should use a menu component in the following way:
Let's assume you have got your CT-Image and CT-Article in a common sitearea called "MyArticle" like this:
MyArticle
CT-Article
CT-Image
Furthermore you need a WCM Menu component which uses two selection criteria:
current sitearea as location
CT-Image as authoring template
So then rendering CT-Article with a presentation template PT-Article you can reference the menu component. Therefore, you reference the menu component in the presentation template markup. The menu component then will pick up the CT-Image and render it as it is located in the same sitearea as your CT-Article.
That's rather a content design approach then a technical approach. It's all there out-of-the-box and saves custom development effort.
If I understand correctly, basically you want to create pre-defined images and then pick one of them to display when you create an article. Correct?
Well, the easiest way would be to utilize what WCM already gives you: create an Image Component. You will be able to upload the image and also provide a description, but you won't be able to set keywords or metadata. The workaround for this would be to set the keywords/metadata as part of the article. If that is okay, this would probably be the best way to do it.
By doing that, all you would have to do is select the relevant Image Component from your Image Element in AT-Article.
If you really need the images to be their own content items (rather than components) so that they have their own keywords and other information, then the next "easiest" way is probably to use an HTML Element inside AT-Article. In this HTML Element you will have to use the "Insert Tag" option, and then choose an Element Tag and use "Selected" rather than "autofill" or "current" to navigate to the content item that you want (the one with the image).
The code will look like this:
[Element name="[path]" type="content" context="selected" key="[element]"]
Where [path] is the path to the content item and [element] is the element that you actually want to pull from that content item (such as image, description, keywords, etc.)
context="selected" is the key there. Then you just need to set up your Presentation Template to be able to use this information that you are pulling in from the HTML Element.
WCM 8.5 has the InContext tag.
The InContext tag renders a tag body within a specified context. The new context can be specified as a predefined context by using a UUID, or by path.
For eg. in this case you can use below where key="Image" in InContext tag is the Link element to the CT-Image content item :
[InContext uuid="[Element context='current' type='content' key='Image' format='id']"]
[Element context="current" type="auto" key="Image"]
[Element context="current" type="auto" key="Description"]
[/InContext]

rendering an AngularJS detail view within list view

I'm a little new to the AngularJS world, and I'm wondering what the best way is to show a resource detail view within a list view.
Given a path like /people, I would just show a list of people resources. If I were to navigate from one of those people to a url like people/john-doe, I can easily get a detail view and all the data associated with that person. But how can I do this without leaving the list view? I'd like to somehow append the detail to the list, or show it within the list, etc.
What you're describing is nested views, which isn't something that the regular ngRoute library does well. I advise you check out angular-ui router.

How can I feed two Marionette modules a piece of info from an appRoute?

I have an app with a Sidebar, which is its own module with its own region, and a primaryRegion that can show views from two other modules (a Dashboard view or a Detail view of an item selected from the sidebar).
When an item gets clicked in the Sidebar, it changes its display to show that it's been selected and gets displayed in the primaryRegion.
The problem I'm running into is that I've recently added routes to the app to directly display item details in the primaryRegion and I can't maintain this behavior when going directly to the Detail view for a given item.
Given that only one module can respond to a route, how can I get the Sidebar to select the item designated in the URL and also display that item's Detail view in the primaryRegion without using a global object or introducing race conditions?
Apologies for the lack of code, I'm having a hard time reducing it down to the essential parts while keeping it clear. Hopefully my description is good enough but if not please let me know and I'll provide more detail.
I can think of two options you could try:
Have Detail fire a global event when it renders, and have the Sidebar be listening for that event and highlight the correct item based on the data it gets from that event.
Or have your Sidebar handle the routing and use a variable route to determine what Detail to render. For example, have a route in the Sidebar of 'details/:id': showDetails' and then a function like:
-
showDetails: function(id) {
// highlight item with id === id here
this.primaryRegion.show(new Details(id));
}

salesforce: How do I set custom tag homepage?

I've created custom object and custom tab (label text="order").
Now my header looks like below just like everyone can do.
[home]__[customer]__[order]
And when I click on "order" tab, I am redirected to home page of "order"
The "order" homepage has:
view (which goes to search feature)
recent record
My question is how do I change the layout of this homepage? I've look though entire site and documentations but seems like it is not possible. The only option I have is to create brand new visualforce page and set that page as default homepage for the "order" tab.
No, you can't change the contents of a default tab homepage beyond the limited controls under Setup. You would have to create a new Visualforce page and replace the page all together; however, with an enhancedList, you can get the basics down without too much coding, like this:
<apex:page>
<apex:enhancedList type="Account" height="500" />
</apex:page>
This would just show the standard Account list views on the tab (which could have Recent Items), but you could spruce things up with other components or make the list view customized with a set controller.

Resources