Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCW 2976 ember upgrade 2.18 #349

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ aliases:

- defaults: &defaults
docker:
- image: circleci/node:boron
- image: circleci/node:10.14.2
working_directory: ~/code
- &restore-repo-cache
key: app-goodcity-repo-{{ .Environment.CIRCLE_SHA1 }}
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
tests:
<<: *defaults
docker:
- image: circleci/node:6-browsers
- image: circleci/node:10.14.2-browsers
environment:
JOBS: 1
steps:
Expand Down
4 changes: 2 additions & 2 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Ember from "ember";
import Application from "@ember/application";
import Resolver from "./resolver";
import loadInitializers from "ember-load-initializers";
import config from "./config/environment";
Expand All @@ -8,7 +8,7 @@ let App;
window.EmberENV = window.EmberENV || {};
window.EmberENV.ENABLE_DS_FILTER = true;

App = Ember.Application.extend({
App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
Expand Down
33 changes: 17 additions & 16 deletions app/components/faq-list.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import Ember from 'ember';
import initFoundation from './init-foundation';
import $ from "jquery";
import { scheduleOnce } from "@ember/runloop";
import initFoundation from "./init-foundation";

export default initFoundation.extend({

didInsertElement() {
this._super();
var topMargin = this.get("session.isLoggedIn") ? 20 : 70;

Ember.run.scheduleOnce('afterRender', this, function(){
var controller = this.get('currentController');
if(controller && controller.questionAnchor) {
controller.send('displayQuestion');
scheduleOnce("afterRender", this, function() {
var controller = this.get("currentController");
if (controller && controller.questionAnchor) {
controller.send("displayQuestion");
}
});

Ember.$().ready(function(){

Ember.$('.faq_list ul').on('click', 'li a', function(){
var anchor = Ember.$(this);
var scrollOffset = Ember.$(anchor.attr('href').split('faq')[1]).offset().top;
$().ready(function() {
$(".faq_list ul").on("click", "li a", function() {
var anchor = $(this);
var scrollOffset = $(anchor.attr("href").split("faq")[1]).offset().top;

Ember.$('html, body').animate({
scrollTop: scrollOffset - topMargin
}, 'fast');
$("html, body").animate(
{
scrollTop: scrollOffset - topMargin
},
"fast"
);

return false;
});
});
}

});
78 changes: 45 additions & 33 deletions app/components/joyride-foundation.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,72 @@
import Ember from 'ember';
import './../computed/local-storage';
import $ from "jquery";
import { computed } from "@ember/object";
import { inject as service } from "@ember/service";
import Component from "@ember/component";
import "./../computed/local-storage";

export default Ember.Component.extend({
store: Ember.inject.service(),
export default Component.extend({
store: service(),

currentUserId: Ember.computed(function() {
currentUserId: computed(function() {
return this.get("session.currentUser.id");
}).volatile(),

isTourSeen: Ember.computed(function() {
isTourSeen: computed(function() {
return this.get("session.seenTour") === this.get("currentUserId");
}).volatile(),

didInsertElement() {
this._super();
var _this = this;

var offerCount = this.get("store").peekAll("offer").get("length");
var itemCount = this.get("store").peekAll("item").get("length");
var recentlyCreated = new Date() - this.get("currentController.model.createdAt") <= 12 * 60 * 60 * 1000; // 12 hrs
var offerCount = this.get("store")
.peekAll("offer")
.get("length");
var itemCount = this.get("store")
.peekAll("item")
.get("length");
var recentlyCreated =
new Date() - this.get("currentController.model.createdAt") <=
12 * 60 * 60 * 1000; // 12 hrs
var isDraft = this.get("currentController.model.isDraft");
var firstEverItem = offerCount === 1 && itemCount === 1 && recentlyCreated && isDraft;
var firstEverItem =
offerCount === 1 && itemCount === 1 && recentlyCreated && isDraft;

if (firstEverItem && !this.get("isTourSeen")) {
Ember.$().ready(function(){
Ember.$(document).foundation({
joyride: {
modal: true,
nub_position: 'top',
tip_animation: 'pop',
tip_location: 'bottom',

pre_ride_callback: function (){
showJoyrideOverlay();
},

post_ride_callback: function(){
hideJoyrideOverlay();
setSeenTour();
$().ready(function() {
$(document)
.foundation({
joyride: {
modal: true,
nub_position: "top",
tip_animation: "pop",
tip_location: "bottom",

pre_ride_callback: function() {
showJoyrideOverlay();
},

post_ride_callback: function() {
hideJoyrideOverlay();
setSeenTour();
}
}
}
}).foundation('joyride', 'start');
})
.foundation("joyride", "start");

Ember.$(".joyride-close-tip").click(function(){
$(".joyride-close-tip").click(function() {
hideJoyrideOverlay();
});

function hideJoyrideOverlay(){
Ember.$(".joyride-view-background").hide();
function hideJoyrideOverlay() {
$(".joyride-view-background").hide();
}

function showJoyrideOverlay(){
Ember.$(".joyride-view-background").show();
function showJoyrideOverlay() {
$(".joyride-view-background").show();
}

function setSeenTour(){
function setSeenTour() {
_this.set("session.seenTour", _this.get("currentUserId"));
}
});
Expand Down
11 changes: 6 additions & 5 deletions app/components/message-box.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Ember from 'ember';
import messageBox from '../templates/components/message-box';

export default Ember.Component.extend({
import Component from "@ember/component";
import messageBox from "../templates/components/message-box";

export default Component.extend({
layout: messageBox,
message: "",
btn1Text: "",
Expand All @@ -27,7 +26,9 @@ export default Ember.Component.extend({
if (this.btn1Callback) {
callbackOutput = this.btn1Callback();
}
if(callbackOutput !== false) { this.close(); }
if (callbackOutput !== false) {
this.close();
}
},

btn2Click() {
Expand Down
76 changes: 45 additions & 31 deletions app/components/new-offer-link.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import Ember from 'ember';
const { getOwner } = Ember;
import { computed } from "@ember/object";
import { inject as service } from "@ember/service";
import Component from "@ember/component";
import { getOwner } from "@ember/application";

export default Ember.Component.extend({
store: Ember.inject.service('store'),
messageBox: Ember.inject.service(),
i18n: Ember.inject.service(),
export default Component.extend({
store: service("store"),
messageBox: service(),
i18n: service(),

allOffers: Ember.computed(function(){
return this.get('store').peekAll("offer");
allOffers: computed(function() {
return this.get("store").peekAll("offer");
}),

existingOffer: Ember.computed('[email protected]', function(){
existingOffer: computed("[email protected]", function() {
var offers = this.get("allOffers");
return offers.filterBy("isUnderReview", true).get("firstObject") ||
return (
offers.filterBy("isUnderReview", true).get("firstObject") ||
offers.filterBy("isReviewed", true).get("firstObject") ||
offers.filterBy("isSubmitted", true).get("firstObject");
offers.filterBy("isSubmitted", true).get("firstObject")
);
}),

locale: function(str){
locale: function(str) {
return this.get("i18n").t(str);
},

Expand All @@ -26,36 +30,46 @@ export default Ember.Component.extend({
this.get("router").transitionTo("offers.new");
},

addNewItem(){
var store = this.get('store');
var loadingView = getOwner(this).lookup('component:loading').append();
addNewItem() {
var store = this.get("store");
var loadingView = getOwner(this)
.lookup("component:loading")
.append();
var offer = this.get("existingOffer");
var defaultDonorCondition = store.peekAll("donorCondition").sortBy("id").get("firstObject");
var defaultDonorCondition = store
.peekAll("donorCondition")
.sortBy("id")
.get("firstObject");

var draft_item = offer.get("items").filterBy("isDrafted", true).get("firstObject");
var draft_item = offer
.get("items")
.filterBy("isDrafted", true)
.get("firstObject");

var item = draft_item || store.createRecord("item", {
offer: offer,
donorCondition: defaultDonorCondition,
state: "draft"
});

item.save()
.then(() => {
loadingView.destroy();
this.get("router").transitionTo("item.edit_images", offer, item);
var item =
draft_item ||
store.createRecord("item", {
offer: offer,
donorCondition: defaultDonorCondition,
state: "draft"
});

item.save().then(() => {
loadingView.destroy();
this.get("router").transitionTo("item.edit_images", offer, item);
});
},

confirmNewOffer() {
if(this.get("existingOffer")) {
if (this.get("existingOffer")) {
this.get("messageBox").custom(
this.locale("offers.index.new_offer_message"),
this.locale("offers.index.new_offer"), () => this.send("addNewOffer"),
this.locale("offers.index.add_item"), () => this.send("addNewItem"),
this.locale("offers.index.new_offer"),
() => this.send("addNewOffer"),
this.locale("offers.index.add_item"),
() => this.send("addNewItem"),
true
);

} else {
this.send("addNewOffer");
}
Expand Down
18 changes: 11 additions & 7 deletions app/controllers/faq.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import Ember from 'ember';
import $ from "jquery";
import Controller from "@ember/controller";

export default Ember.Controller.extend({
export default Controller.extend({
questionAnchor: null,

actions: {
displayQuestion() {
var question = this.get("questionAnchor");
if(question) {
var scrollOffset = Ember.$("#" + question).offset().top;
if (question) {
var scrollOffset = $("#" + question).offset().top;

Ember.$('html, body').animate({
scrollTop: scrollOffset - 70
}, 'fast');
$("html, body").animate(
{
scrollTop: scrollOffset - 70
},
"fast"
);
}
return false;
}
Expand Down
Loading