How to allow signed-in users to delete read items in telescopeapp? - telescope

How do I customise my telescope app, such that users can delete or hide an item if they don't want it to be included in the list anymore - for example, if they have already seen it and aren't interested in it. The list of items would then need to be re-ordered, so that the deleted item no longer shows, and all of the items below it are bumped up. I would want it to be possible for a user to delete all of the items individually if they wanted to, and then a message would be visible which would say that there are no items to show.
I essentially want to mimic the 'archive' function in Apple Mailbox where the email is no longer visible in a user's inbox.
Note: the user would only be deleting the item from his own view of the main list, this shouldn't affect the list that any other user can see.

It sounds like you need to add a couple things:
A new view.
A new viewedPosts array as a custom field on the user object.
A markPostAsRead method that adds a post to that array.
Some kind of UI control to call that method from the client.
The view would use the current user ID to retrieve the viewedPosts array from the user object, and then filter out any posts that are included in that array both on the server and client.

Related

ColdFusion convert hidden form variables to a structure

The app I am working on has hidden input variables set on initial load of the page. The variables need to be accessed across all pages. The reason for not converting these to session variables is the user can open another browser with different parameters and passing those value as hidden inputs make it work without any issue. What is the best possible alternative so as to get rid of these hidden inputs..I tried converting all variables into a Structure, but again the structure needs to be posted as part of form submission to make it available to subsequent pages.Another disadvantage of this app is use of frames.I don't have any code to post.
It sounds as if you want different browsers instances which are associated with the same web session to maintain their own distinct sets of data. Doing this by passing form or url variables around seems like a bad idea.
One approach that you could use would be, onSessionStart (or as required), create a structure in the users session to hold instances of the data. For example
session.data = {
someRandomKey: {
valueA: 42,
valueB: "Porridge"
}
}
Then just pass someRandomKey as a hidden form field or querystring parameter. Now, when they submit the form to update variables you use the id from the hidden form field to find the appropriate structure from session.data.
When the user needs a new instance of this form, give them some way, like a link or button, that creates a new unique key, inserts a struct in session.data with this key and populates it with whatever defaults are needed then loads the form passing along the new id as a hidden form field or querystring param again.

How can I clear a specific filter without clearing all filters?

Background:
I am creating an app that stores record of trainings that employees in a company took in table. I want to filter the rows of the table based on training name and/or employee name. I was able to figure out this first part, and I was able to create a button that clears all the filters and reloads the entire table using the clearFilters() function.
Problem:
I want to create two buttons that clear the filter selections one ("All Trainings") for the training name and one ("All Employees") for the employee name. To be more clear, when I click on the "All Trainings" button, I want to clear the filters on the training name, but not on the Employee name. This will become useful once I have a table with multiple fields that I want to filter, and I want to navigate the table without having to reset all fields every time.
I tried searching the functions available on Google App Maker, but there was nothing that seemed to be able to solve my problem. Any suggestions?
From the Reference about datasources:
https://developers.google.com/appmaker/models/datasources#query_datasources
Like field filters, assigning null to a relation filter property clears that restriction.
So, something like:
datasource.query.filters.Employee._contains = null;
datasource.load();
should work for you.
I am sure there is a better way to do this, so you may want to wait for someone smarter to chime in, but I BELIEVE you can just have your button clear the filters, but reapply a new filter.
So for my situation I have the table do a filter for items that are listed as "Complete", so those are hidden when the user opens the page.
Then, when the users filter another field and want to clear out that search I didn't want the "Complete" items to reappear (which is what happened when I just used the clearFilters() function. So my workaround was to make the clear button actually clear the filter, but apply the original "Complete" filter.
So for my OnClick action, for my "Clear Button" I have:
widget.datasource.query.clearFilters();
widget.datasource.load();
app.closeDialog();
var datasource = app.datasources.TestModel;
datasource.query.filters.Status._notContains = 'Complete';
datasource.load();
The
widget.datasource.load();
app.closeDialog();
May be redundant/unnecessary.
Can you simply take 3 steps in your onClick handler?
(1) clear all filter
(2) set the employee name filter
(3) load data

"Create or update" form behavior when hitting back button

I have the following workflow on a website:
Some user John Doe declares a company through form 1
(fields: name, head office location)
After John Doe submits (HTTP POST) form 1, he is redirected (HTTP 302) to company form 2 with additional legal information about the company.
The problem is, if John Doe hits the back button of his browser during step 2, he will land on the form 1, with data filled by the browser (using values he already submitted — that's what Firefox and major browsers seem to do).
John Doe might then think he can use this form to update some information (e.g. fix a typo in the name of the company) whereas he will actually create a new company doing so, as we don't know on the server side whether he wants to declare a new company or update the one he just created.
Do you know any simple solution to handle that problem ?
Use javascript/jquery script after the page is loaded to empty all the inputs. This will prevent confusion of "updating the company".
jQuery would look something like this:
$('#elementID').val('');
You can also handle the situation by manipulating the browser history
on load of form 2, and pass the CompanyId generated on submit of form 1 using querystring. So that you can actually update the company as the user
Suppose John submits form1.html, a unique CompanyId "1001" is generated and redirected to form2.html. Now on load of form2 you can modify the browser history form1.html?companyid=1001 using
var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 1", "form1.html?companyid=1001");
Now, when the user click back button and submits the form1 again. you can check for companyid in querystring and update the company.
I think it is more user-friendly when user can return back to previous form and update it (instead preventing the described behavior).
I use in most cases similar way to handle described problem:
Let's assume that user is on the page /some-page, that contains "Create new company" button.
When the user opens this page, will be executed special method createOrFindCompanyDraft() on the server-side. This method creates new company "draft" record in DB (only for the current user). For example, draft record has primary key id=473. When you execute this method again it will return the same record with the id=473 (with "draft" status). "Draft" record should't display on any other interfaces.
And "Create new company" has link /company/common/473.
When user go to /company/common/473, you display form 1, that will be filled from "draft" record. At first time user will see empty form.
Technically user will update the existing record, but you can display "Create new company" title on the page.
Then user go to form 2, for example, /company/legal-info/473, you create similar draft record for the this form (similar to step 1).
When user submit the form 2, you will remove "draft" status from the record id=473 (and any related records).
Next time when user open page /some-page, will be created new draft record for the current user.
Browser history will contain:
/some-page
/company/common/473
/company/legal-info/473
/some-page2
I like this approach, because all form only update records. You can go to previous/next form many times (for example "Back"/"Forward" browser buttons). You can close browser, and open not completed forms tomorrow. This way doesn't require any additional manipulation with the browser history.
try this
<form autocomplete="off" ...></form>
And Another
Use temporary tables or session to store the Page 1 form data. If the page 2 form is submitted use the temporary data of page 1 which is stored in database or in session.
Use a Separate key (Hidden field ) in both page 1 and page 2.
Actually I thought of a trick to obtain that "create on first post, update after" behavior (just like the user thinks it should behave).
Let's say the step 1 form is at the URL /create_company/. Then I could have that page generate a random code XXX and redirect to /create_company/?token=XXX. When I create the company I save the information that it was created through page with token XXX (for instance, I save it in user's session as we don't need to keep that information forever) and when the form is submitted, if I know that a company was already generated using this token, I know the user used the same form instance and must have used the back button since the token would be different if he explicitly asked for another company.
What do you think ? (I initially thought there should be a simpler solution, as this seems a little bit over-engineered for such a simple issue)
This is more like a UX question.
I'd think that the solution lies within the information given to the user on that form, to help them understand what they're doing.
Set a title that says 'Create a company', for example, and set your submit button as 'Create Company' will help your user with that. Use a unique id when you create the company object, and pass the id back to the same URL in order to perform an update. You should then update your title and button that tells user that they are updating instead of creating.
In that sense I'd say it's better to use a more generic URL like /company and /company?id=12345.
You could also consider using Restful API protocol to help your server identifies the CRUD operation. http://www.restapitutorial.com/lessons/httpmethods.html
Without the "routing" part of django it is hard to help. I can just answer my experience from the express.js-router functionality:
you can specify a post on /company, which is for new users.
you can specify another route for post on /company/:companyid for a changing form
and as a response from the create-post you can redirect to the different location.

selecting multiple items in an AS3 list component based on values

I've created a flash AS3 user form for sales people. When I create a user, I select multiple cities from a list component and drop them into an array. When added to the mySQL DB these entries are kept in a separte table which I can then call upon at any time using XML to bring them back into AS3. Now I'm using the same form as a user updaete form and populating it with data from previous MySQL insert.
My question is - How could I have these cities show as 'selected' on the list Component when the update form is loaded? Thus allowing the someone to add to or substract from that selection set. I'm trying to set selectedItems to match the ID's in the XML but failing miserably.
as a test I tried
addUser.citiesList.selectedItems = [3,4];
addUser.citiesList.selectedIndices = [3,4];
The selectedItems yield nothing but the selectedIndices works but I don't want to start matching indexes with Item ID's
looked all over but can't seem to find an answer. Am I missing something or is this not possible?
Well I finally got it working.
Having got the data out of the MySQL db, through PHP and into Flash as XML, I then pushed the user city values into a userCity array.
I got the AS3 list component in the form populated in the same way with all the cities.
I then used the userCity array in a nested for loop to inerate through all the cities in the list component, picking out the ones that had been previously selected and grabbing the index of each to pop into a new array which was the array used for the 'selectedindicies' and hey presto. I now have a cities list (about 36 cities) with the previously selected cities (about 5 cities) already selected and highlighted so that the user knows which cities the sales peson already manages. Now they can add or subtract from that and it will be picked up by my on change event as normal.
The Adobe resources on selectedIndices and selectedItems, for someone like me, who's learning is to say the least - pittyful...
I hope this helps someone else out...

Flex/AS3: removing item from ListCollectionView

I used a temporary array to populate a ListCollectionView. Later, I have a screen that displays a DataGrid using the ListCollectionView as a dataProvider. The user can delete a row in the DataGrid by selecting the row then clicking a Delete button.
How can I access the original source that ListCollectionView uses, and delete the item from there?
After I do that, will the item also be deleted from the ListCollectionView automagically, and no longer be shown in the DataGrid (or does something need to be refreshed)?
UPDATE 1
Does the following sound like I'm on the right track? (I want to remove it from the source (is that the ".list"?) of the ListCollectionView, not just from ListCollectionView.)
[Bindable] private var _myLCV:ListCollectionView=new ListCollectionView(new ArrayList());
...
var obj:Object = _myLCV.getItemAt(myGrid.grid.selectedIndex); // get item user selected
_myLCV.list.removeItemAt( _myLCV.list.getItemIndex(obj) ); // delete item from source
UPDATE 2
I'm not sure why (I'm using SDK 4.5.1A), but I seem to need to add the following line of code to the above code in UPDATE 1, for the DataGrid to reliably update and show the deleted row:
_myLCV.refresh();
My impulse is to recommend deleting the item from the ListCollectionView using removeItemAt.
If you truly want to access the source instead of dealing with the collection, then it depends what type of ListCollectionView you're using.
If you're using an ArrayCollection you can access the source using the source property.
IF you're using an XMLListCollection, you can access the source using the source property.
There isn't an inherent source property in the ListCollectionView, but the List property may suffice.
In any case, removing an item from the ListCollectionView or the ListCollectionView's source should automatically update the DataGrid. IF not, you can call the refresh() method on the collection.
Spark DataGrid, like other list base controls such as List or even DataGroup, would observe change events from its dataProvider. The change events may include item removal, update, sort and insertion. This provides the convenience of updating the control by just updating its underlying data.
That said, if your intent is to "refresh" the datagrid to stay up to date with the LIstCollectionView, by modifying the array and then refresh would rather be unnecessary.