Permalink
Browse files

Added the append() method to wing.object_list in wing.vue.js.

  • Loading branch information...
rizen committed Feb 5, 2019
1 parent 9f06f17 commit d29944b91256366ba517817b0399bcd0f4c03e63
Showing with 43 additions and 16 deletions.
  1. +1 −0 CHANGES.txt
  2. +24 −0 lib/Wing/WingVue.pod
  3. +18 −16 public/wing.vue.js
@@ -6,6 +6,7 @@ with respect to new features and compatibility changes.

2019-02-05
* Modified S3Image to allow verification of an image outside of the handle upload method.
* Added the append() method to wing.object_list in wing.vue.js.

2019-02-04
* Modified S3Image to allow for images not attached to other objects by passing '-none-' into image_relationship_name.
@@ -585,6 +585,30 @@ A javascript object that holds parameters waiting to be used in a new object tha

{ }

=head3 append(properties, options)

Adds a new object ot the list that you created via some other method.

=over

=item properties

The properties list returned for this object via the REST API.

=item options

An object containing various things that should be done with the data when it is appended.

=over

=item on_each

A function to be executed when an object as it is appended. It will be passed the properties of the object, and the C<objectManager> instance of the object.

=back

=back

However, you can set default values in this object by setting C<new_defaults> when you create the list. C<new> will also be reset to C<new_defaults> whenever C<reset_new()> is called.

=head3 reset_new()
@@ -346,12 +346,13 @@ const wing = {

fetch : function(options) {
const self = this;
if (!self.fetch_api) {
const fetch_api = (typeof self.properties !== 'undefined' && typeof self.properties._relationships !== 'undefined' && self.properties._relationships.self) || self.fetch_api;
if (!fetch_api) {
console.error('wing.object fetch_api is empty');
}
const promise = axios({
method:'get',
url: wing.format_base_uri((typeof self.properties !== 'undefined' && typeof self.properties._relationships !== 'undefined' && self.properties._relationships.self) || self.fetch_api),
url: wing.format_base_uri(fetch_api),
params : self.params,
withCredentials : behavior.with_credentials != null ? behavior.with_credentials : true,
});
@@ -605,6 +606,19 @@ const wing = {
});
},

append : function(properties, options) {
const self = this;
const new_object = self._create_object(properties);
self.objects.push(new_object);
if (typeof options !== 'undefined' && typeof options.on_each !== 'undefined') {
options.on_each(properties, self.objects[self.objects.length -1]);
}
if (typeof behavior.on_each !== 'undefined') {
behavior.on_each(properties, self.objects[self.objects.length -1]);
}
return new_object;
},

search : _.debounce(function(options) {
return this._search(options);
}, 200),
@@ -634,13 +648,7 @@ const wing = {
self.objects = [];
}
for (var index = 0; index < data.result.items.length; index++) {
self.objects.push(self._create_object(data.result.items[index]));
if (typeof options !== 'undefined' && typeof options.on_each !== 'undefined') {
options.on_each(data.result.items[index], self.objects[self.objects.length -1]);
}
if (typeof behavior.on_each !== 'undefined') {
behavior.on_each(data.result.items[index], self.objects[self.objects.length -1]);
}
self.append(data.result.items[index], options);
}
self.paging = data.result.paging;
const items = data.result.items;
@@ -684,13 +692,7 @@ const wing = {
promise.then(function (response) {
const data = response.data;
for (var index in data.result.items) {
self.objects.push(self._create_object(data.result.items[index]));
if (typeof options !== 'undefined' && typeof options.on_each !== 'undefined') {
options.on_each(data.result.items[index], self.objects[self.objects.length -1]);
}
if (typeof behavior.on_each !== 'undefined') {
behavior.on_each(data.result.items[index], self.objects[self.objects.length -1]);
}
self.append(data.result.items[index], options);
}
if (typeof options !== 'undefined' && typeof options.on_success !== 'undefined') {
options.on_success();

0 comments on commit d29944b

Please sign in to comment.