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

WIP: add support for google maps autocomplete #257

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@model Bonsai.Code.DomainModel.Facts.Models.AutoCompletePlaceFactModel
<span>@Model.ShortTitle: @Model.Value</span>
13 changes: 13 additions & 0 deletions src/Bonsai/Areas/Admin/Views/Pages/Editor.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@
</div>
</script>

@if (Environment.GetEnvironmentVariable("AutoComplete__Google__AuthToken") != null)
{
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&key=@(Environment.GetEnvironmentVariable("AutoComplete__Google__AuthToken"))"></script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function () {
var elements = document.querySelectorAll('[id=autocomplete-fact]');
for(var i = 0; i < elements.length; i++) {
new google.maps.places.Autocomplete(elements[i]);
}
});
</script>
}

@foreach (var tpl in data.EditorTemplates)
{
await Html.RenderPartialAsync(tpl);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script type="text/x-template" data-kind="fact-template" id="AutoCompletePlaceFactModel">
<div class="fact-wrapper">
<h6>
{{def.title}}
<button type="button" class="btn btn-outline-secondary btn-sm" v-if="empty()" v-on:click="set({Value: ''})" title="Указать факт">
<i class="fa fa-plus"></i>
</button>
</h6>
<div v-if="!empty()" class="row">
<div class="col-sm-8">
<div class="fact-long">
<input id="autocomplete-fact" type="text" v-model="data[def.key].Value" class="form-control form-control-sm mr-2" />
<button type="button" class="btn btn-sm btn-outline-danger btn-remove-fact" v-on:click="unset" title="Удалить факт">
<i class="fa fa-remove"></i>
</button>
</div>
</div>
</div>
</div>
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@using Bonsai.Code.DomainModel.Facts.Models
@model AutoCompletePlaceFactModel

<tr class="fact">
<th class="fact-title">@Model.ShortTitle</th>
<td class="fact-value">@Model.Value</td>
</tr>
12 changes: 6 additions & 6 deletions src/Bonsai/Code/DomainModel/Facts/FactDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ static FactDefinitions()
"Рождение",
true,
new FactDefinition<BirthDateFactModel>("Date", "Дата рождения", "Дата"),
new FactDefinition<StringFactModel>("Place", "Место рождения", "Место")
new FactDefinition<AutoCompletePlaceFactModel>("Place", "Место рождения", "Место")
),
new FactDefinitionGroup(
"Death",
"Смерть",
true,
new FactDefinition<DeathDateFactModel>("Date", "Дата смерти", "Дата"),
new FactDefinition<StringFactModel>("Place", "Место смерти", "Место"),
new FactDefinition<AutoCompletePlaceFactModel>("Place", "Место смерти", "Место"),
new FactDefinition<StringFactModel>("Cause", "Причина смерти", "Причина"),
new FactDefinition<StringFactModel>("Burial", "Место захоронения")
new FactDefinition<AutoCompletePlaceFactModel>("Burial", "Место захоронения")
),
new FactDefinitionGroup(
"Bio",
Expand Down Expand Up @@ -77,16 +77,16 @@ static FactDefinitions()
"Рождение",
true,
new FactDefinition<BirthDateFactModel>("Date", "Дата рождения", "Дата"),
new FactDefinition<StringFactModel>("Place", "Место рождения", "Место")
new FactDefinition<AutoCompletePlaceFactModel>("Place", "Место рождения", "Место")
),
new FactDefinitionGroup(
"Death",
"Смерть",
true,
new FactDefinition<DeathDateFactModel>("Date", "Дата смерти", "Дата"),
new FactDefinition<StringFactModel>("Place", "Место смерти", "Место"),
new FactDefinition<AutoCompletePlaceFactModel>("Place", "Место смерти", "Место"),
new FactDefinition<StringFactModel>("Cause", "Причина смерти", "Причина"),
new FactDefinition<StringFactModel>("Burial", "Место захоронения")
new FactDefinition<AutoCompletePlaceFactModel>("Burial", "Место захоронения")
),
new FactDefinitionGroup(
"Bio",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Bonsai.Code.DomainModel.Facts.Models
{
/// <summary>
/// The template for specifying arbitrary string-based facts.
/// </summary>
public class AutoCompletePlaceFactModel: StringFactModel
{
}
}