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 2538 ember upgrade of shared.goodcity to 2.18 #268

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 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:carbon
- image: circleci/node:10.14.2
working_directory: ~/code
- &restore-repo-cache
key: shared-goodcity-repo-{{ .Environment.CIRCLE_SHA1 }}
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
tests:
<<: *defaults
docker:
- image: circleci/node:8-browsers
- image: circleci/node:10.14.2-browsers
steps:
- restore-cache: *restore-repo-cache
- restore-cache: *restore-yarn-cache
Expand All @@ -73,7 +73,7 @@ jobs:
root: .
paths:
- coverage*/lcov.info

deployment:
<<: *defaults
steps:
Expand Down
53 changes: 29 additions & 24 deletions addon/controllers/messages_base.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
import Ember from "ember";

export default Ember.Controller.extend({
messageLinkConvertor: Ember.inject.service(),

import $ from 'jquery';
import { debounce } from '@ember/runloop';
import { observer, computed } from '@ember/object';
import { on } from '@ember/object/evented';
import { alias, sort, notEmpty } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import Controller, { inject as controller } from '@ember/controller';

export default Controller.extend({
messageLinkConvertor: service(),
body: "",
offerController: Ember.inject.controller("offer"),
messagesUtil: Ember.inject.service("messages"),
offerController: controller("offer/offer_details"),
messagesUtil: service("messages"),
isPrivate: false,
inProgress: false,
offer: Ember.computed.alias("offerController.model"),
offer: alias("offerController.model"),
sortProperties: ["createdAt:asc"],
sortedElements: Ember.computed.sort("messagesAndVersions", "sortProperties"),
isItemThread: Ember.computed.notEmpty("item"),
sortedElements: sort("messagesAndVersions", "sortProperties"),
isItemThread: notEmpty("item"),

autoMarkAsRead: Ember.on('init',
Ember.observer('isActive', 'messages.[]', '[email protected]', function() {
autoMarkAsRead: on('init',
observer('isActive', 'messages.[]', '[email protected]', function() {
if (this.get('isActive')) {
Ember.run.debounce(this, this.markConversationAsRead, 1500);
debounce(this, this.markConversationAsRead, 1500);
}
})
),

disabled: Ember.computed("offer.isCancelled", "item.isDraft", function() {
disabled: computed("offer.isCancelled", "item.isDraft", function() {
return this.get("offer.isCancelled") || this.get("item.isDraft");
}),

groupedElements: Ember.computed("sortedElements.[]", function() {
groupedElements: computed("sortedElements.[]", function() {
return this.groupBy(this.get("sortedElements"), "createdDate");
}),

allMessages: Ember.computed(function() {
allMessages: computed(function() {
return this.store.peekAll("message");
}),

messages: Ember.computed("allMessages.[]", "offer", "item", function() {
messages: computed("allMessages.[]", "offer", "item", function() {
var messages = this.get("allMessages");
messages = this.get("isItemThread") ?
messages.filterBy("itemId", this.get("item.id")) :
Expand All @@ -45,7 +50,7 @@ export default Ember.Controller.extend({
});
}),

messagesAndVersions: Ember.computed(
messagesAndVersions: computed(
"messages.[]",
"itemVersions",
"packageVersions",
Expand All @@ -59,7 +64,7 @@ export default Ember.Controller.extend({
}
),

itemVersions: Ember.computed(
itemVersions: computed(
"item.id",
"allVersions.[]",
"isItemThread",
Expand All @@ -74,7 +79,7 @@ export default Ember.Controller.extend({
}
),

packageVersions: Ember.computed(
packageVersions: computed(
"item.packages",
"allVersions.[]",
"isItemThread",
Expand All @@ -94,11 +99,11 @@ export default Ember.Controller.extend({
}
),

allVersions: Ember.computed(function() {
allVersions: computed(function() {
return this.get("store").peekAll("version");
}),

offerVersions: Ember.computed(
offerVersions: computed(
"allVersions.[]",
"offer.id",
"isItemThread",
Expand Down Expand Up @@ -141,7 +146,7 @@ export default Ember.Controller.extend({
actions: {
sendMessage() {
// To hide soft keyboard
Ember.$("textarea").trigger("blur");
$("textarea").trigger("blur");

this.set("inProgress", true);
var values = this.getProperties("body", "offer", "item", "isPrivate");
Expand All @@ -165,7 +170,7 @@ export default Ember.Controller.extend({
})
.finally(() => this.set("inProgress", false));

Ember.$("body").animate({ scrollTop: Ember.$(document).height() }, 1000);
$("body").animate({ scrollTop: $(document).height() }, 1000);
}
}
});
38 changes: 20 additions & 18 deletions addon/controllers/offer/transport_details.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import Ember from 'ember';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import { alias } from '@ember/object/computed';
import Controller from '@ember/controller';
import { getOwner } from '@ember/application';

export default Ember.Controller.extend({
delivery: Ember.computed.alias('model.delivery'),
contact: Ember.computed.alias('delivery.contact'),
hasActiveGGVOrder: Ember.computed.alias('delivery.gogovanOrder.isActive'),
messageBox: Ember.inject.service(),
i18n: Ember.inject.service(),
isDonorApp: Ember.computed.alias("session.isDonorApp"),
export default Controller.extend({
delivery: alias('model.delivery'),
contact: alias('delivery.contact'),
hasActiveGGVOrder: alias('delivery.gogovanOrder.isActive'),
messageBox: service(),
i18n: service(),
isDonorApp: alias("session.isDonorApp"),

user: Ember.computed(function(){
user: computed(function(){
var userId = this.get("model.createdBy.id") || this.session.get("currentUser.id");
return this.store.peekRecord('user', userId);
}).volatile(),

userName: Ember.computed('contact.name', 'user.fullName', function(){
userName: computed('contact.name', 'user.fullName', function(){
return this.get('contact.name') || this.get("user.fullName");
}),

userMobile: Ember.computed('contact.mobile', 'user.mobile', function(){
userMobile: computed('contact.mobile', 'user.mobile', function(){
return this.get('contact.mobile') || this.get("user.mobile");
}),

district: Ember.computed('contact.address.district.name', 'user.address.district.name', function(){
district: computed('contact.address.district.name', 'user.address.district.name', function(){
return this.get('contact.address.district.name') || this.get("user.address.district.name");
}),

Expand Down Expand Up @@ -51,17 +55,15 @@ export default Ember.Controller.extend({
},

removeDelivery(delivery) {
var _this = this;

this.get("messageBox").custom(this.get("i18n").t("delete_confirm"), this.get("i18n").t("delivery.cancel.cancel_transport"), () => {
var loadingView = _this.container.lookup('component:loading').append();
var loadingView = getOwner(this).lookup('component:loading').append();
var offer = delivery.get('offer');

delivery.destroyRecord()
.then(function() {
.then(() => {
offer.set("state", "reviewed");
var route = _this.get('session.isAdminApp') ? 'review_offer' : 'offer.offer_details';
_this.transitionToRoute(route, offer);
var route = this.get('session.isAdminApp') ? 'review_offer' : 'offer.offer_details';
this.transitionToRoute(route, offer);
})
.finally(() => loadingView.destroy());
}, this.get("i18n").t("not_now"), null);
Expand Down
4 changes: 2 additions & 2 deletions addon/router/router.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';
import EmberRouter from '@ember/routing/router';

var Router = Ember.Router.extend();
var Router = EmberRouter.extend();

Router.map(function() {
this.route('i18n', { path: '/i18n' });
Expand Down
7 changes: 4 additions & 3 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import Ember from 'ember';
import config from '../config/environment';
import ActiveModelAdapter from 'active-model-adapter';
import { inject as service } from "@ember/service";
import { computed } from "@ember/object";

export default ActiveModelAdapter.extend({

namespace: config.APP.NAMESPACE,
host: config.APP.API_HOST_URL,
session: Ember.inject.service(),
session: service(),

headers: Ember.computed("session.authToken", function(){
headers: computed("session.authToken", function(){
return {
"Authorization": `Bearer ${this.get('session.authToken')}`,
"Accept-Language": this.get('session.language'),
Expand Down
1 change: 1 addition & 0 deletions app/adapters/offer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ApplicationAdapter from "./application";
import config from '../config/environment';


export default ApplicationAdapter.extend({

urlForQuery: function(query, modelName){
Expand Down
26 changes: 14 additions & 12 deletions app/components/book-van.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
import Ember from 'ember';
import $ from 'jquery';
import { scheduleOnce } from '@ember/runloop';
import Component from '@ember/component';

export default Ember.Component.extend({
export default Component.extend({
didInsertElement() {
this._super();

Ember.run.scheduleOnce('afterRender', this, function(){
scheduleOnce('afterRender', this, function(){
validateInputs();
validateForm();
});

function validateForm(){
Ember.$('.book_van').click(function(){
Ember.$.each(['.pickadate', '.timepicker'], function(i, input){
checkInput(Ember.$(input));
$('.book_van').click(function(){
$.each(['.pickadate', '.timepicker'], function(i, input){
checkInput($(input));
});
if(Ember.$('.has-error').length > 0) { return false; }
if($('.has-error').length > 0) { return false; }
});
}

function validateInputs(){
Ember.$('.pickadate, .timepicker').focusout(function(){
$('.pickadate, .timepicker').focusout(function(){
return checkInput(this);
});
Ember.$('.pickadate, .timepicker').focus(function(){
$('.pickadate, .timepicker').focus(function(){
return removeHighlight(this);
});
}

function checkInput(element){
var parent = Ember.$(element).parent();
var value = Ember.$(element).val();
var parent = $(element).parent();
var value = $(element).val();

if(value === undefined || value.length === 0) {
parent.addClass('has-error');
Expand All @@ -39,7 +41,7 @@ export default Ember.Component.extend({
}

function removeHighlight(element){
var parent = Ember.$(element).parent();
var parent = $(element).parent();
parent.removeClass('has-error');
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/components/check-box.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';
import Component from '@ember/component';

export default Ember.Component.extend({
export default Component.extend({
attributeBindings: ['type', 'value'],
tagName: 'input',
type: 'checkbox',
Expand Down
7 changes: 4 additions & 3 deletions app/components/cloudinary-image-tag.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from 'ember';
import { bind } from '@ember/runloop';
import Component from '@ember/component';

export default Ember.Component.extend({
export default Component.extend({
loading: true,

changedSrc: function() {
Expand All @@ -20,7 +21,7 @@ export default Ember.Component.extend({
},

didInsertElement() {
var updateScreen = Ember.run.bind(this, this.onLoad);
var updateScreen = bind(this, this.onLoad);
this.$(".cl-item-image").on("load", updateScreen);
},

Expand Down
15 changes: 9 additions & 6 deletions app/components/cloudinary-upload.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import Ember from "ember";
import $ from 'jquery';
import { run } from '@ember/runloop';
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import AjaxPromise from '../utils/ajax-promise';
import config from '../config/environment';

export default Ember.Component.extend({
export default Component.extend({
tagName: "input",
type: "file",
accept: "image/*",
Expand All @@ -16,8 +19,8 @@ export default Ember.Component.extend({
disabled: true,
offerId: null,

messageBox: Ember.inject.service(),
i18n: Ember.inject.service(),
messageBox: service(),
i18n: service(),

didInsertElement() {
var _this = this;
Expand All @@ -40,15 +43,15 @@ export default Ember.Component.extend({
// forward cloudinary events
["submit","progress","always","fail","done"].forEach(ev => {
if (this[ev]) {
options[ev] = (e, data) => Ember.run(() => this.sendAction(ev, e, data));
options[ev] = (e, data) => run(() => this.sendAction(ev, e, data));
}
});

var reqData = this.get("offerId") ? { tags: `offer_${this.get('offerId')}` } : {};
new AjaxPromise("/images/generate_signature", "GET", this.get('session.authToken'), reqData)
.then(function(data) {
if ( !(_this.get('isDestroyed') || _this.get('isDestroying')) ) {
Ember.$(_this.element)
$(_this.element)
.attr("data-form-data", JSON.stringify(data))
.cloudinary_fileupload(options);
_this.set("disabled", false);
Expand Down
4 changes: 2 additions & 2 deletions app/components/custom-img-tag.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';
import Component from '@ember/component';

export default Ember.Component.extend({
export default Component.extend({
tagName: 'img',
attributeBindings:['src'],
src: null,
Expand Down
Loading