Skip to content

Commit

Permalink
Merge pull request #417 from crossroads/master
Browse files Browse the repository at this point in the history
Release[0.17.1] : Image fix + Various bugs
  • Loading branch information
patrixr authored Apr 8, 2020
2 parents 9e8df98 + 8f809ac commit 300ffe5
Show file tree
Hide file tree
Showing 24 changed files with 737 additions and 149 deletions.
8 changes: 4 additions & 4 deletions app/components/date-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ export default Ember.TextField.extend({

onClose: function() {
Ember.$(document.activeElement).blur();
const [minDate, maxDate] = [cmp.get("minDate"), cmp.get("maxDate")];
this.set("min", minDate || "");
this.set("max", maxDate || "");
},

onOpen: function() {
const date = cmp.get("model");
this.set("val", date ? date : null);
const [minDate, maxDate] = [cmp.get("minDate"), cmp.get("maxDate")];
this.set("min", minDate || "");
this.set("max", maxDate || "");
},

onSet: function() {
// Support for callback
var onSelect = cmp.get("onSelect");
const date =
this.get("val") || (this.get("select") && this.get("select").obj);
if (_.isFunction(onSelect)) {
if (isValidDate(date) && _.isFunction(onSelect)) {
onSelect(date);
}
}
Expand Down
42 changes: 25 additions & 17 deletions app/components/package-image.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,54 @@
import Ember from 'ember';
import Ember from "ember";

export default Ember.Component.extend({

store: Ember.inject.service(),
displayUserPrompt: false,
selectedImage: null,

// images: Ember.computed.alias("package.item.images"),

currentPackage: Ember.computed("package", function() {
return this.get("store").peekRecord("package", this.get("package.id")) || this.get("package");
return (
this.get("store").peekRecord("package", this.get("package.id")) ||
this.get("package")
);
}),

images: Ember.computed("currentPackage.item.images.[]", "currentPackage.packageImages.[]", function() {
// if(this.get("currentPackage.packageImages.length") > 0) {
// return this.get("currentPackage.packageImages");
// } else {
return this.get("currentPackage.item.images");
// }
}),
images: Ember.computed(
"currentPackage.item.images.[]",
"currentPackage.images.[]",
function() {
const pkgImages = this.getWithDefault(
"currentPackage.images",
[]
).toArray();

return this.getWithDefault("currentPackage.item.images", [])
.toArray()
.filter(im => !pkgImages.findBy("cloudinaryId", im.get("cloudinaryId")))
.concat(pkgImages);
}
),

actions: {

selectImage(image) {
this.get("images").setEach("selected", false);
image.set("selected", true);
this.set("selectedImage", image);
},

setPackageImage() {
var image = this.get("selectedImage");
this.get("package").favouriteImage = image;
this.sendAction("setPackageImage", this.get("index"), image);
this.sendAction("setPackageImage", this.get("currentPackage"), image);
},

displayImagesListOverlay() {
if(this.get("images").length > 0) {
if (this.get("images").length > 0) {
this.set("displayUserPrompt", true);
var favouriteImage = this.get("package.favouriteImage");
if(favouriteImage) { this.send("selectImage", favouriteImage); }
if (favouriteImage) {
this.send("selectImage", favouriteImage);
}
}
}
}

});
Loading

0 comments on commit 300ffe5

Please sign in to comment.