Build Ember Power-Select component - ember.js

Wondering if Ember power-select can be used as follows.
I have a model that has related records. I'm trying to use PS to pick from one of that list in order to set another related record. To explain more fully, here is the final end state. (This is for a singing competition, models Capitalized):
each Contestant sings multiple Songs
each Song has one Chart
each Contestant submits multiple Submissions (in advance) for pre-clearance
each Submission has one Chart
i'm trying to use power-select to pick the Chart for each Song, from the pre-cleared Submission list specific to each contestant.
I can get parts of things working, but can't get the whole thing together because (i think) i'm trying to line up Submissions and Charts, which are related but different items.
so, on a page that represents a Contestant model, i'm trying to do:
{{power-select options=model.submissions onchange=(action pseudo-code: save selected submission.chart to model.chart.)}}
I know this is a difficult question for the format, but i'm hopelessly stuck
UPDATE: I still think i'm missing something. Here is the schema that shows all the models and their relations.
In this context, the main 'page' (ie, the 'model') is the Performance. Each performance has multiple songs (two, to be precise), which for UI purposes I'd prefer to show simultaneously. So I am using an {{#each model.songs as |song|}} in this context to pick the chart. Each song has one parent chart. As a further complication, the chart for a given song does not necessarily have to be present on the submission table; but in most cases that's how the chart list will be restricted.
So ultimately what i'm trying to do is have a filtered list of chart objects, according to what has been submitted via the submission table (which is essentially a many-to-many pass through. Ultimately i'm looking to save the chart field on the song model, so that means two power-select components on the performance page.
pretty complicated question, i know. but with any luck the i've conveyed the problem accurately... thanks

If I got the idea, you just want to set a belongsTo relationship when the user choose an option.
{{#power-select
options=model.submissions
selected=model.chart
onchange=(action (mut model.chart) value="chart") as |submission|}}
{{submission.name}}
{{/power-select}}
When a submission is chosen, it will just call model.set('chart', submission.chart)

Related

Show items with no data when filtering by field

Is there a way of filtering using a field but still keep showing items which don't have a value?
I have prepared a quick dummy test:
On the left, when i filter by "indicator name" by 'This' and 'that' values, countries with no data on either categories disappear. On the right, when it's not filtered, we see other countries even if they have no data. My problem is that I actually have a hundred indicators, that is why i need to filter that.
'Show items without data' has been already marked.
Is there a way around the filter to show all countries?
Model looks like this:
The work-around is to create a Measure and adding "+0".

Multiplechoice widget with really big lsit

In my model Person can have more than one partner, so the ManyToMany Model is the only answer (this has to be ManyToMany for other reasons, so please don't think about changing it).
If I use default widget i got a list of all persons with selected one, two maybe three persons (which are partners of Person).
It would be ok, if the Person list is about 10-100 - and it works on test database. But my prod database has 10.000 persons or more, so the ModelMultipleChoice widget would be filled with 10.000 records, and finding the correct partner will last ages, and memory usage isn't trivial.
I need only to see names of partners with possibility to unset it from person, and some possibility to add new just typing name. The best solution is to show listbox with filtered names after typing three or four first letters, but any solution would be great.
With forms it would be easier, but I need it in admin, so I'd like to use django admin standards.

Can i change an item in a list from another list?

I´ve created a list in SharePoint. What i´ll like to do is create another list, and retrieve some information from one list to my new one, and be able to change the input data from list A in a single line of text.
So lets say, list A is PopStar, with columns like Genre "Rock", HairColor "Red" and GrammyCount "2".
In list B i only want textboxes to show whats in list A and be able to change (update) them, for example Genre to "Pop", HairColor to "Black" and GrammyCont to "8" ?
Is this possible?
i´m using office 365
In order to achieve exactly what you want you will require either a Workflow or an Event Receiver, however I assume you won't feel confident by struggling with such approaches, furthermore, there are some workarounds that could be very close to your requirement and maybe are even better solutions than the approach you suggest, in terms of maintenance, growth and upgrade.
I suggest to review topics like "SharePoint parent/child list webparts connections" or "sharepoint edit form add child items", here are two videos of which you can get some ideas.
https://www.youtube.com/watch?v=9PWIxk6rF-A
https://www.youtube.com/watch?v=-5CdjfLONgE
Take in count that you can do more than what is displayed in the videos, by example in the Edit Form you could add a webpart to display the Quick Edit View (Grid View) of the related list so the values can be edited in the same Form and thus removing the need to navigate to a second window.

Kendo datasource and templates, specifically for Scheduler widget

I've noticed that the scheduler widget does things a bit differently from other widgets. In fact, I read in the documentation that the DS is a different one:
"http://docs.kendoui.com/api/framework/schedulerdatasource"
Anyways, on to my two questions.
when i was doing a template for the day cells, i noticed that if i used value called 'date' it would automatically use the correct date value for that day cell. But i never created this date variable, not did i include it in my datasource. So where did it come from? if its provided through framework, what other values similar to this one are available to me? where can i find some documentation on this?
For kendo widgets, when you apply a datasource and a template, it automatically maps each datasource item to one item in the widget (e.g. one row in the grid, one item in the list view etc.). its a one to one correlation. But this is not the case for the scheduler datasource since, like i stated above, it is a different type of datasource (its a schedulerdatasource). The scheduler datasource mandates that each item in the datasource have a start date and an end date so it can map it to the corresponding cell. hence, this destroys the one-to-one relationship of datasource item to day [template]. How can i revert to the behavior of the datasource with other widgets? do i have to somehow configure it to overwrite the schedulerdatasource to the original datasource? i want to preserve the correlation behavior of 1-to-1 between my datasource and my day template.
just to give a generic example of what i am trying to accomplish with this, imagine that instead of doing entrys with time slots, i want to instead have my scheduler display daily summaries of how many hours i worked out, how many calories i ate, amount of hours i slept etc. But i do not want to associate those amounts with hours in the day.
--
Sorry that was technically more than two questions.
But thanks in advance!
-B
Straight to your questions:
The options available in the eventTemplate are listed in the documentation.
The SchedulerDataSource does one thing more than the regular DataSource - it expands recurring events. This means that for one event which says repeats two days the SchedulerDataSource creates two data items - one for each day. If you don't have any recurring events then you would have the one-to-one mapping. The scheduler can only be bound to a SchedulerDataSource instance (it will throw an exception otherwise).
It looks that the scheduler may not be the widget you are looking for. If you just want to display a list of items the ListView or Grid widgets may be a better fit.

Django admin store dynamic formset added with ajax

I'm currently implementing a solution using django admin, it allows users to define in the db a product, and then custom attributes and details, more details may be aggregated by a common attribute, this allows me to query with ajax a custom view that returns some JSON data to build automagically the form fields that I need directly in the same formset view (manipulating the DOM).
The current DB design follows this schema:
Catalog(name, description, photo)
Product(rel_catalog, name, base_price, photo, manufacturer_email)
ProductDetail(rel_product, rel_attribute, percentage_price, fixed_price)
ProductAttribute(rel_product, name, description)
As you may see I have a catalog, where there can be more products, a lot of details per product, aggregated by attributes. Then I simple show by default the Catalog, then the select with all available products for that catalog, then, choosing the right Product, I obtain the complete form (each row has a label with ProductAttribute.name and a select with related ProductDetail).
All works pretty dam good, but I also need to store this references in the DB when someone completes the form (making an order with choosen products). This forms are displayed as StackedInline (the ModelAdmin is for the Order).
I don't know how many options there may be per product so I was thinking to use this design to track orders:
Order(customer, status, notes, tot_price, inserted_by)
OrderItem(rel_order, catalog, product, unit_price)
But I don't know how to store the dynamic added inputs...
I was thiking to implement OrderItemProperty(rel_orderitem, rel_productdetail, rel_productattribute) to store each single input... but how do I loop over this unknown fields?
Maybe do you suggest a better design?
If you need more code just ask for it and I'll reply with a pastebin link.
Thankyou.
Finally I got a working solution,
I've created a custom view, overriding the default "add/" view, this way I can customize whatever I want to and I can read the POST data handling each validation, putting then the data in the right model.