ReactJS - make text input that contains tags and free text as template - reactjs

I'm researching an easy way to make a free text input that can also contain multiple replaceable tags to create templates. As on this picture example
In that picture, the information witch player (tag) made the goal would be stored.
Later I would reuse that template and replacing the tag by a value.
Like: Goal of Iniesta, Goal of Rivaldo, ...
I couldn't find a lib that would do the job. The few attempts that I made to try to resolve it lead to extremely complex inputs with redefining selects (onClick, onKeydown, onSelect, maintaining current select) as the user can't edit the tag by hand (they are trigger by clicking buttons).
Does somebody already had to handle this kind of input?
Edit: As my question seems to be not clear, I will add a few details.
In fact, the input should work as it is a free text input but should also allow adding tags/chips that are provided by external triggers (onClick buttons)
Example: I will make [activity] on [day]
First I type "I will make " then I click the button "activity" that will add a "activity" tag/chip to the input. I continue with typing " on " and finaly click the button "day" to add the tag "day".
Then I will store this as template and reuse it in several scenarios by replacing the tags. Like:
I will make sandwiches on Monday
I will make sport on Friday

If somebody else have the same issue. I finally found the right lib Tagify. It has a mixed mode (text + tag)

Related

outputting checkbox ids to an empty div

I am currently building a keyword bank to assist in tagging my in-house design assets. My idea is to have each keyword as a checkbox form element with one empty div at the bottom. You'd go through the entire list, check what you need and the text assigned to the id of that checkbox would populate in the empty div, separated by commas, and I can just copy/paste that text right into the metadata. I plan on having hundreds, so I'm hoping there is simple solution to this.
I have no problem setting up the html form/checkboxes, but I am unsure how to make this text populate in that empty div—or even IF it's possible. Would I use jQuery? Ajax? I also don't need a submit button—just that div to update immediately each time a checkbox is touched. Would I also need to have some server-side communication with a submit button to even make this work?
Thank you so much in advance for any help you can give or any direction you can point me in.
Here is a working fiddle
What you need is basically something like this :
$( ":checkbox" ).click(function() {
//alert($( this ).val());
$("#myText").append($(this).val() + ";");
});
You can forget the alert. This will add the value assigned to the checkbox in the div followed with a coma. :)

How to specify PathToSubformControl for BrowseTo in access 2010

Could someone help me with BrowseTo macro plsease? I cannot figure out one of the arguments in the this macro in ACCESS 2010 which is PathToSubformControl. I have this Form called "frm_navigation":
The names of all Tab are: nav_vacancies, nav_contacts, nav_organizations etc.
The field "Organization name" in the figure will hold the name from another table tbl_organizations. However, the Tab "Organizations" (the third from left) will display all info from the table tbl_organizations.
I would like to program a button that takes me to Organization Tab and set a current record according to the name displayed in the field "Organizations name".
So far I did it via DoCmd.OpenForm but it filters out all other records and opens a new window. I tried to set BrowseTo action as follows:
DoCmd.BrowseTo acBrowseToForm, "frm_Organizations", "frm_navigation.nav_organizations", "[tbl_organizations].[PR_ID]=" & Me.cb_org_name.Value
but I've got runtime error as my PathToSubformControl is wrong. How am I supposed to specify the path? I cannot understand the structure. It's supposed to follow this pattern: MainForm1.Subform1 > Form1.Subform1 but it's not explained what is what.
Thanks
Very late reply, but...
In your code, "frm_navigation.nav_organizations" needs to specify the name of the NavigationSubForm subform control (by default it is NavigationSubForm).
Let me try to re-state your command with generic names:
DoCmd.BrowseTo acBrowseToForm, "frmToDisplayInNavSubCtl", "frmMainFormContainingNavSubFrmCtl.NavSubFrmCtl", ....criteria....
So, in short, you need to go into design view on your frm_navigation form and determine the name of the NavigationSubForm control, not the names of the navigation buttons (e.g., nav_organizations, nav_vacancies, etc.) and use that after the dot, instead of .nav_organizations (the name of the button control).

ZK window not unique in ID space

In our project we use ZK for webpages. There is a combobox which has lists. When selected, it fetches data from a java object through onSelect, i have given the logic.
when i select one there are 4 listboxes on that page to be filled with data according to the selection. when i select first time, no problem occurs.
But on second time i get an error pop-up like "Not Unique in the id space of Window" and showing the list box item id which have to be filled on select.
Can any one help out there?
Note: Though it shows this error i get the listboxes filled correctly according to the combo box selection. Still i cant stop this error occurring..
Your issue is a conflict of ids in ZK's id space.
A bit of background..
ZK generates ids for components at runtime, if you open up the DOM in the browser you'll see each component has some machine readable id.
However, you can also give components an id. This id does not go to the DOM but lets you reference the component in your application.
These two shouldn't be confused. The conflict you're experiencing is with the latter type of id; you are assigning a component an id in your Java code or in your ZUL file which, at runtime, is not unique.
The case you describe where it only happens the second time you click is a tell tale sign here. The content you are adding on the event has an id defined in it and you are not removing this content when you are done.
Consider the following example:
#Wire
private Window myWindow;
#Listen(Events.ON_CLICK + " = #myButton")
public void onMyButtonClicked() {
Label myLabel = new Label("sean is cool");
myLabel.setId("myLabel");
myLabel.setParent(myWindow);
}
This will work the first time you click myButton, but will throw your error on the second click. That is because the second event tries to add myLabel to myWindow but there is already a myLabel there.
There are lots of ways to resolve this depending on what you are trying to do.
Have a look through the ZK documentation on ID Spaces for more.
I also faced the same error.
My scenario is the same, only the widgets being used are different.
Hence putting my workaround here.
I have put the following piece of code in the doBeforeCompose() method of the composer:
Component widgetWithId = page.getFellowIfAny("widgetWithId");
if (widgetWithId != null) {
widgetWithId.detach();
}
Here widgetWithId is the component/widget, which is tried to be regenerated by the code, with the same Id and ZK is throwing error for it.

Render a page differently based on which list that opened it

I have two lists of different PageTypes - NewsItems and PressReleases. They are displayed in one list each, with links to the individual items.
Now I want to include the press release items into the news list and use the style of the news items to display them as news items. They share properties like "Heading" and "BodyText", which are used in the News Template.
I imagine that it won't be that difficult to feed the NewsItems' ListPage with both sets of pages, but I don't understand how I can control the rendering of the item page.
I would like to take the PageData object from a NewsItem OR a PressReleaseItem and display it using the News-Item.aspx template, if it is selected in a NewsList. But EPiServer will always render the PressReleaseItem with the PR-Item.aspx since it's coupled in the PageType settings.
Anyone know how to accomplish this?
EDIT: An effort to clarify:
The important issue is how to know the "list parent" and choose the right template from that. In the ListPage I can apply different looks on the PR and News items respectively using tompipes answer, but when selecting to see an individual item EPi will render the PR-Item-1 the same way regardless of their "list parent". That's the problem.
I'm not following exactly what you are attempting here. But I think I get the gist of it.
Why not use one aspx template for both page types, but in the code behind switch off sections using the visible attribute.
If you are using PageTypeBuilder you could use the "is" keyword:
somePlaceHolder.Visible = CurrentPage is NewsItemList;
If you're not using PTB, you could use something like:
somePlaceholder.Visble = CurrentPage.PageTypeID == 10;
or
somePlaceholder.Visble = CurrentPage.PageTypeName == "NewsItemList";
I'll point out now I'm not a fan of hardcoding anything, so I would place the template name, or ID into a config file, or a property on the start/root page to avoid hardcoding them.
Let me know if this will help, or if I have misunderstood please try elaborate on your issue.
Depending on how much the templates share you could go with user controls, placeholders or even different masterpages to switch view in a suitable way.
To know when to switch you could use a querystring parameter, session variable or the nicest looking way would probably be to lookup and get the list's PageData object by the HTTP referrer. If it's empty you will get press release rendering as the worst case.
I tried lots of solutions, including the adding of querystring to the PR items in the list links, the getting of referring url in the item template and different types of event hooking for automatic publishing of news items from a PR item (although I only looked at the code samples for that one), and finally came to the conclusion that they all had something that told me not to go that way. (Making the code too complex, or the markup logic too hard to understand and so forth)
I ended up using Fetch data from another EPiServer page, and creating a "shortcut pagetype" in which I let my editors pick which PR item should be used as base for a news item.
This shortcut pagetype is called "PR-as-news-itemPage" and it is rendered with the same aspx as ordinary news items: News-Item.aspx. Having no properties of its own, it will take all relevant data from the PR item selected with "Fetch..."
To render PR items with all its properties I created an ordinary new pagetype called PR-Item.aspx. This renders the "Attribute 2" property, which is only rendered by PR-item.aspx, and not by News-Item.aspx.
(I could have gone even simpler, by letting the editors use the old News-Item page type and use the "Fetch..." property there, but I have some mandatory properties in that page type which I didn't want to make optional for this sake.)

How to prefill a field of a node using rules in Drupal7?

Using rules it's easy to fill field values of a node after user pressed the save button. Just add a rule on before saving content event. But is it possible to have a rule to prefill a node field before edit form is shown to the user? So he has a change to corrent the default values.
This is a very late reply, but hopefully someone might find it to be of some help:
If you are creating the node using Rules, you could save it first, selecting "Force saving immediately: true". In the next step, you could set the value of the node field. You might need to save again. (also 'Force save' immediately.) And in the next step, do a 'page redirect' to the edit url.
Not sure if this is an elegant way to do it, but it might work. I had a somewhat similar requirement (not the same), and this is how I finally did that - by saving first, and then redirecting to the edit url of the saved node.
Not sure if this is something you can accomplish with rules or not, but if you go to structure->content types you can click "manage fields" and edit the default value of any field other than the title field (which you could always turn off and replace with a custom title field with a default value)
I think there are basically two ways of doing this:
1) Use Rules Forms. I don't know very much about that module, and I have had some less than perfect experiences with the module, but I'm fairly certain it could be done with the module.
2) Use Rules to create a node, populate the relevant field values, and then send the user to the edit page. One downside with this approach is that if the user decides to abort the node creation, you'll end up with a half-populated node that needs deletion in one way or another.
If you choose to go for option 2, and are comfortable with Page manager and Panels, it is probably worth checking out the Rules Panes module.

Resources