Skip to content
Merged
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: 4 additions & 0 deletions assets/javascripts/discourse/components/location-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export default class LocationForm extends Component {

@action
updateGeoLocation(gl) {
if (!this.showInputFields) {
gl = this.geoLocation;
}

gl["zoomTo"] = true;

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default Controller.extend(ModalFunctionality, {
state: gl.state,
geoLocation: { lat: gl.lat, lon: gl.lon },
countrycode: gl.countrycode,
rawLocation: gl.raw,
rawLocation: gl.address,
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@
{{#if this.showGeoLocation}}
<LocationSelector
@location={{this.geoLocation}}
@onChange={{action this.updateGeoLocation}}
@class="input-xxlarge location-selector"
{{on "searchError" this.searchError}}
{{on "searchError" @searchError}}
@context={{this.context}}
/>
{{else}}
Expand Down
2 changes: 1 addition & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-locations
# about: Tools for handling locations in Discourse
# version: 6.3.3
# version: 6.3.4
# authors: Angus McLeod, Robert Barrow
# contact_emails: development@pavilion.tech
# url: https://github.com/angusmcleod/discourse-locations
Expand Down
25 changes: 7 additions & 18 deletions test/javascripts/acceptance/topic-and-user-card-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers";
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import userFixtures from "../fixtures/user-fixtures";
import topicFixtures from "../fixtures/topic-fixtures";
Expand Down Expand Up @@ -36,38 +36,27 @@ acceptance(

test("topic title location, post user & user card location - shows correct format", async function (assert) {
await visit("/t/online-learning/51/1");

assert.equal(
query("span.location-text").innerText,
"Pompidou, Paris, France"
);

assert.equal(
query(".small-action-desc.timegap").innerText,
"2 years later"
);

assert.equal(query("#post_3 .user-location").innerText, "Paris, France");

assert.equal(query('a[data-user-card="merefield"]').innerText, "");

await click('a[data-user-card="merefield"]');

assert.equal(
query(".user-card .location-label").innerText,
"London, United Kingdom"
);
});

test("enter Topic location via dialogue", async function (assert) {
await visit("/t/online-learning/51/1");
await click("a.edit-topic");
await click("button.add-location-btn");

assert.equal(query(".add-location-modal").style.display, "block");
await fillIn(".input-large:first-child", "liver building");
await click("button.location-search");
await click("li.location-form-result:first-child label");
await click("#save-location");

assert.equal(
query("button.add-location-btn span.d-button-label").innerText,
"Royal Liver Building, Water Street, Ropewalks, L3 1EG, Liverpool, United Kingdom"
);
});
}
);
3 changes: 3 additions & 0 deletions test/javascripts/acceptance/topic-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ acceptance("Topic List- Show Correct Topic Location Format", function (needs) {

test("topic on topic list location - shows correct format", async function (assert) {
await visit("/latest");

assert.ok(
exists('tr[data-topic-id="36"] span.location-after-title'),
"Pompidou, Paris, France"
);
});

test("topic on topic list location - doesn't include location after title span when there is no location", async function (assert) {
await visit("/latest");

assert.equal(
query('tr[data-topic-id="35"] span.location-after-title'),
null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {
acceptance,
emulateAutocomplete,
query,
} from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import topicFixtures from "../fixtures/topic-fixtures";
import siteFixtures from "../fixtures/site-fixtures";
import locationFixtures from "../fixtures/location-fixtures";
import { cloneJSON } from "discourse-common/lib/object";

acceptance(
"Topic - Show Correct Location after entering location with Input Fields Disabled",
function (needs) {
needs.user({
username: "demetria_gutmann",
id: 134,
});
needs.settings({
location_enabled: true,
location_input_fields_enabled: false,
location_auto_infer_street_from_address_data: false,
});
needs.site(cloneJSON(siteFixtures["site.json"]));
needs.pretender((server, helper) => {
const topicResponse = cloneJSON(topicFixtures["/t/51/1.json"]);
server.get("/t/51/1.json", () => helper.response(topicResponse));
const locationResponse = cloneJSON(locationFixtures["location.json"]);
server.get("/location/search", () => helper.response(locationResponse));
});

test("enter Topic location via dialogue without address fields", async function (assert) {
await visit("/t/online-learning/51/1");
await click("a.edit-topic");
await click("button.add-location-btn");

assert.equal(query(".add-location-modal").style.display, "block");

await emulateAutocomplete(".location-selector", "liver building");
await click("li.location-form-result:first-child label");

assert.equal(
query(".location-selector-container .item span").innerText,
"Royal Liver Building, Water Street, Ropewalks, Liverpool, Liverpool City Region, England, L3 1EG, United Kingdom"
);

await fillIn(".location-name", "Home Sweet Home");
await click("#save-location");

assert.equal(
query("button.add-location-btn span.d-button-label").innerText,
"Home Sweet Home"
);
});
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import topicFixtures from "../fixtures/topic-fixtures";
import siteFixtures from "../fixtures/site-fixtures";
import locationFixtures from "../fixtures/location-fixtures";
import { cloneJSON } from "discourse-common/lib/object";

acceptance(
"Topic - Show Correct Location after entering location with Input Fields Enabled",
function (needs) {
needs.user({
username: "demetria_gutmann",
id: 134,
});
needs.settings({
location_enabled: true,
location_input_fields_enabled: true,
location_auto_infer_street_from_address_data: true,
});
needs.site(cloneJSON(siteFixtures["site.json"]));
needs.pretender((server, helper) => {
const topicResponse = cloneJSON(topicFixtures["/t/51/1.json"]);
server.get("/t/51/1.json", () => helper.response(topicResponse));
const locationResponse = cloneJSON(locationFixtures["location.json"]);
server.get("/location/search", () => helper.response(locationResponse));
});

test("enter Topic location via dialogue", async function (assert) {
await visit("/t/online-learning/51/1");
await click("a.edit-topic");
await click("button.add-location-btn");

assert.equal(query(".add-location-modal").style.display, "block");

await fillIn(".input-large:first-child", "liver building");
await click("button.location-search");
await click("li.location-form-result:first-child label");
await click("#save-location");

assert.equal(
query("button.add-location-btn span.d-button-label").innerText,
"Royal Liver Building, Water Street, Ropewalks, L3 1EG, Liverpool, United Kingdom"
);
});
}
);