Tracking/Storing a variable across views with AngularJS - javascript

I am coding a pretty simple app that allows users to make certain selections and receive a random quote based on their selections. I have a pretty good idea on how to actually produce the quote but am stuck on how to track user selections until they get to the final view/page.
Specifically, my question is, how do I go about storing the user's selections in a variable or an array in a way that I can use it both on the last page and update it from any page for the quote generation? I haven't been using Angular for that long but what I've tried so far is making a service that includes an array for storing variables and then using directives on the buttons to update the array but this seems messy in the end with so many selections and it doesn't actually work right now.
Any and all suggestions or resources on how to achieve what I want are greatly appreciated <3

Defined this in my app.js
myApp.value('selection', {
first: "first choice here",
second: "second choice here"
});
And this in the controllers, updating the 'selection' based on the current view/ctrl along with the obvious necessary dependency injection
selection.first = "updated choice";

Related

Elasticsearch, Vue and Innersearch.vue -- Search won't recognize inputs with spaces in them

I've been tinkering with Innersearch for a project. I really like Vue and this app, but this might be a deal breaker.
I have it connected to my Elasticsearch instance. It pulls and display the data, but when I use the search box, it will not search on any phrase that has a space in it. It looks like the ":function" prop controls the query types. When I change it from "match" to "match_all", I notice the behavior of the search changes.
With that, it appears the prop starts after whether you can declare "bool => should", for example. I've been reading up and down in Elasticsearch's JS documentation and nothing is really helpful to this issue. I'm more familiar with the php-elasticsearch client.
I've read in other places that I would have to reindex my data, but the mapping is already set at "keyword" for the data I have. And, besides that, when I was using the php-elasticsearch client, I didn't need to change the mapping.
So, I'm kind of at a loss. I can't tell if I'm missing something in the Elasticsearch JS syntax, or if Innersearch has left off the ability to do this. If anyone has any experience with this, I'd appreciate it.

Problems saving a firebase database with angularjs

i've been using Firebase for a couple of months now, and it's been great along with angularjs and anfularfire, before i explain the problem, let me give you a fast background: i am currently using different controllers for an app that is meant for users to register plant species and to use them as items to create an interactive garden. In order to save the database from any controller, i stored the reference into the $scope
var rootRef = firebase.database().ref();
$scope.database = $firebaseObject(rootRef)
so when i want to make a change or add an object, i do it like this:
$scope.example_function = function(i){//supposing 'i' is a string
$scope.element[e] = i //supposing that 'e' contains a string
$scope.database.$save()
}
Sometimes this works, other times it just doesn't save the firebase, specially when editing existing objects inside the database or adding an element to an specific object. It's really frustrating because it doesn't throw an error or something, i even tried deleting the path i wanted to change and then storing it again with the new info. Also i tried with local references to the database in each controller, but nope... Anyone knows how else can i make this work?
Also. I am pretty sure the connection between the database and the app is fine, i got to store lots of species by now, the problem is when i want to edit the info from the species or add an url to get an image.
I don't think it's a good idea to bind your entire database to a the scope. It will be extremely hard to scale.
Remember that when you request for a ref and send it to $firebaseObject it will register to change events and this will start sync of your entire database which might potentially be huge.
For the issues you're experiencing, it looks like you're binding the database reference to a database property of $scope but in your example_function you're applying values to an element property. So maybe the fix you're looking for is something like:
function example_function(i) {
$scope.database.element = i;
$scope.database.$save();
}

Netsuite: How to edit or update a record?

I am a newbie at NetSuite scripting. It looks like a normal EDIT or UPDATE function is not at all normal in the Netsuite. There are APIs for creating and deleting record like nlapiCreateRecord and nlapiDeleteRecord, but nowhere in the documentation I could find the way to edit and update the existing record. I have restrictions on using PHP.
I have created a custom TFC customer form (server side js), which should be able to fetch the data and update if required. I have been able to fetch the records as of now, but please tell me how to update an existing record?
To be a little more precise, use nlapiLoadRecord to fetch the record from the database. Set the fields as needed. Use nlapiSubmitRecord to save it.
Untested code off the top of my head:
var record = nlapiLoadRecord('record_type_goes_here', internal_id_of_record_goes_here);
record.setFieldValue('field_internal_id_goes_here', 'value to set goes here);
nlapiSubmitRecord(record);
Fill in the appropriate values where needed.
For the benefit of anyone looking at this question who is concerned with performance, it is much more efficient to use
nlapiSubmitField(type, id, fields, values, doSourcing)
If you know exactly what you are updating. This is both faster than submitRecord, and avoids the often significant overhead of loading the record first.
The function used to edit an existing record is nlapiSubmitRecord. See definition here http://suitecoder.appspot.com/static/api.html

Sharepoint - How to: dynamic Url for Note on Noteboard

I'm quite new to SharePoint (about 1 week into it actually) and I'm attempting to mirror certain functionality that my company has with other products. Currently I'm working on how to duplicate the tasking environment in Box.com. Essentially it's just an email link that goes to a webpage where users can view an image and comments related to that image side by side.
I can dynamically load the image based on url parameters using just Javascript so that part is not a problem. As far as the comments part goes I've been trying to use a Noteboard WebPart, and then my desire is to have the "Url for Note" property to change dependent on the same URL parameter. I've looked over the Javascript Object Model and Class Library on MSDN but the hierarchy seems to stop at WebPart so I'm not finding anything that will allow me to update the Url for Note property.
I've read comments saying that there's a lot of exploration involved with this so I've tried the following:
-loading the javascript files into VisualStudio to use intellisense for looking up functions and properties in the SP.js files.
-console.log() on: WebPartDefinitionCollection, WebPartDefinition, WebPart, and methods .get_objectData(), get_properties() on all the previous
-embedding script in the "Builder" on the Url for Note property (where it says "click to use Builder" - I'm still not sure what more this offers than just a bigger textbox to put in the URL path)
I'm certain I've missed something obvious here but am gaining information very slowly now that I've exhausted the usual suspects. I very much appreciate any more resources or information anyone has and am willing to accept that I may be approaching this incorrectly if someone has accomplished this before.
Normally I'd keep going through whatever info I could find but I'm currently on a trial period and start school back up again soon so I won't have as much time with it. Apologies if this seems impatient, I'm just not sure where else to look at the moment.
Did you check out the API libraries like SPServices or SharepointPlus? They could help you doing what you want...
For example with SharepointPlus you could:
Create a Sharepoint List with a "Note" column and whatever you need to record
When the user goes to the page with the image you just show a TEXTAREA input with a SAVE button
When the user hits the SAVE button it will save the Note to the related list using $SP().list("Your list").add()
And you can easily retrieve the information (to show them to the user if he goes back to the page) with $SP().list("Your list").get()
If I understood your problem, that way it may be easier for you to deal with a customized page :-)

Need help with using Crud 1.1 and jqgrid

I found this Crud 1.1 that someone put together on the CI forums and I just edited it so I could query different column names. The problem is when I try to edit a row it seems to be still using the column 'id' in the query. I can't for the life of me figure out what could be referencing that column name.
Has anyone used this template to do something similar?
This could be a stupid question but have you done a "search in files" for the value "id" in the CRUD folder structure? I'm sure its there and you just missed it..
This approach would at least track down the ID element. Keep in mind modifying this library in this fashion will cause greater headaches when/if you want to update to a never version (when it comes out that is).

Categories

Resources