Issues on a select with AngularJS and Google Spreadsheet - angularjs

I want to create a small web app which would display a list of movies, with a Google spreadsheet set as a database. So far, I was able to connect my spreadsheet to my app and I also added some filters to it. (As a side note, this thread really helped me in the process.)
Here is a very simplified version of my app: http://plnkr.co/edit/BtbSCVOh7KJsMHjANxMP?p=preview
I still have 3 problems with my <select>, which I can't fix despite trying for hours:
I can't sort my <options> alphabetically. Trying with orderBy didn't return anything.
I can't figure out a way to split my categories when there are more than one for a movie.
If the "categorie" field in my spreadsheet is empty, it will return a blank <option> which I would like to remove or hide.
My guess is that I'll need to update my function one way or another, but I'm a bit lost at the moment.
Any help on this would be really appreciated!

Related

How can I sort and map my SQL query in Ionic?

I have a database running in the background, the aim of the whole thing should be that I have categories as buttons and that categories should be created under elements. I separated the whole thing in the database (i.e. in two tables), i.e. in categories and in the sub-elements. I get everything correctly selected but just don't know how to assign or build it. Does anyone have any ideas or examples to look at?
I've already tried Ionic's list system. Just like ion-record.

ReferenceInput with nested CheckBoxGroupInput behaving strangely

I have looked around for many hours and tried various things but alot of the examples i see for CheckBoxGroupInput simply have a hardcoded list of choices associated which is a bit useless... My scenario here is that i have a list of tags that i want to be able to associate with a product, pretty common stuff..
i need that list to be fetched from the postgres database... and that part all seems to work and my list looks normal when first rendered on the create screens for react-admin... The control looks like below
<ReferenceInput reference="ProductRealBenefit" source="realbenefits" sort={{ field: 'name', order: 'ASC' }}>
<CheckboxGroupInput source="name" />
</ReferenceInput>
This all well and good so far..
it renders my list as expected.. i have my schema all set up according to the format for ra_data_graphql_simple... Thing that is unexpected, is that as soon as i click on one of the tags, it immediately sends off a request to the server for the allProductRealBenefit query with a filter value equal to the clicked id and it adds a duplicate of that clicked tag to the list which breaks the control with a duplicate key error... i don't see why it would be sending off a request after i click anyway, i am not trying to save anything just assemble which tags would be sent off with the form data to create the link records, and i already have all that data after the initial populating of the control..
i am guessing maybe this should not be nested in ReferenceInput but i don't see any other way to populate my choices with database query result. I know this is ridiculously common functionality & I'll need to figure out a way to use this in multiple spots because this tagging functionality should be available in multiple resources.. I also tried this with AutocompleteArrayInput and it had similar issues so i know the problem is i must be missing an important step.... Be great if someone can point be in the right direction. i am going back to the docs for now to see what i can dig up!
OK, i am gonna answer another one of my questions in case anyone lands here equally as upsidedown as i was when i asked it... I simply didn't realize what some of the behind the scenes magic was doing therefore i was using this wrong... And i find the docs confusing
In my example above... my ProductRealBenefits in the reference was a one to many relationship represented in my schema with realbenefits: [ProductRealBenefits]... Therefore i needed the following components.
<ReferenceArrayInput label="Real Benefit Tags" source="realbenefitsIds" reference="ProductRealBenefit">
<CheckboxGroupInput optionValue="id" optionText="name" allowEmpty />
</ReferenceArrayInput>
There is a little magic in the ra_data_graphql_simple dataProvider that creates an item for you in state called realbenefitsIds, which is what you use as the source for the ReferenceArrayInput, i was trying to use the actual realbenefits array object, and that was not gonna work. I could not find any good examples out there or any decent explanations on how to get this to work... So ultimately it was Redux Dev Tools that saved my bacon here. I had to jump through some hoops in the graph server to get all this working with the dataprovider sending back diff things for GET_MANY and GET_REFERENCE_MANY filter values, but that was just a matter of parsing the filter args to match what sequelize was expecting. I'll end up writing a dataProvider eventually but this fit the bill for now..
PS.. i was seeing some strange behaviour in my CheckboxGroupInput, when i clicked something it duplicated whatever box was clicked... The reason for that was an error in object type in my schema... There was an Int mixed in with ID, and luckily that showed up in Redux Dev Tools and led me to the problem.
Lastly.. I'm putting together a sample project in Github that will use React-Admin, GraphQL, RA_DATA_GRAPHQL_SIMPLE, Sequelize, and a Postgres Database and i will comment it alot to take some of the confusion out of it for anyone like myself... Cheers!!

Outputting Stripe plan name via plan-ID using AngularJS ng-model two-way data binding

I am outputting form inputs on the final page of a checkout field, titled "Review & checkout"... on this page I display the plan the customer picked and the personal info they provided so far.
I have no problem showing fields like Name or Email, as the value inputted is being shown, as Angular displays whatever was in the value="" field of the input.
To display the subscription plan that the customer picked, it's trickier.
The value field is already being utilized to tell stripe which plan the customer should be charged for.
How can I get around this problem?
I am able to display the stripe-id for the plan but it is not user-friendly. They are id's like trad-2-5, trad-2-6, trad-2-7... so what I want to do is display a custom title when trad-2-5 is selected, and so on...
Any help is greatly appreciated!!Thanks
There are a couple of ways you could do this.
The really silly answer is that you can just create a map of plan ids to human-readable descriptions in the Angular controller code, then display that. This might be enough for what you want, but it's also pretty hacky, and not a lot of fun to maintain.
The less silly answer depends on where these plan ids are coming from. If they are coming from an endpoint on your server, which gets them from Stripe's plans endpoint, then you could also pass along the display name of the plan from that endpoint. If the plan id's are hard coded somewhere, or whitelisted, then this may not make sense. However, that display name is what will appear on the customer's invoice, and credit card statement, so it'd be nice to make it match up with what they see on the checkout page.

Get content Id (nid) from path on views block

I just can't seem to wrap my head around Drupal relationships. I have been reading and watching tutorials, but as soon as I try to get my own project done - I fail. I think it's very basic, so I would love to understand it. Maybe someone here can help me understand how it works :)
On my drupal site, I want to keep track of some private game tournaments.
I have created a content type called contestant, which has fields like: Tournament date, Player name, Final Position. I can then create a view that list the information from one tournament. I used the help I got from this thread: drupal views dynamic filter
I would like to have the view described above as a block. And then place that block-view on a "tournament description" page. I could do this, by simply creating a new block each time, and then manually place it on the page it should be shown (structure-->Blocks-->configure), but that is not an elegant way to do it. I am pretty sure this is where Relationships should be used. But I fail to understand how to create this relationship, so that the specific block view, that matches the specific tournament description page will be displayed together.
Use a Content:Nid as a Contextual filter.
WHEN the Filter value is not in the URL >>
Provide default value
Content ID from URL

Cognos : Persisting Checkbox state across Multiple Pages

On the Cognos Report Results Page, we need to have a checkbox for each row.
The checkbox is designed using HTMLITEM tag.
However, the problem we face is that the state of the checkbox (checked or unchecked) is not persisted when we go to the next page/previous page.
I am very new to Cognos and I need to know if there is a way to do this.
I am fairly good at JAVAScripting and JSP, but since we only have access to HTML elements and not JSP Tags (Cognos uses CGI anyways), I cannot get the request object.
If there is some way to retrieve the request objects parameters of previous submit(previous page), that would help in solving the issue to a large extent, I feel.
Jonas
There isn't really enough information on what your end goal is to be able to assist you with this properly. There are a few ways that spring to mind that would allow you to use JS on the report to remember previously checked items, but there may be a much better way to do this depending on your requirements.
Without having more details, the first thing that leaps to mind is simply having some JavaScript set and unset cookie values on check/uncheck on the checkbox.
Note, there could be a variety of other ways to work this, including upping the number of visible rows per page, etc...
You can create a dataitem in a query where you can determine whether your checkbox should be checked or not. In the design of your list on the report page you can render a HTMLItem within the list, and base the HTMLItem on a DataItem. Your HTML must than be something like
<input type="checkbox" value="""+ [DataItemValueToPass] + """ " + [DataItemCheckedOrNot] ></input>

Resources