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

Add address lookup field #1138

Open
wants to merge 32 commits into
base: include-address-donate-form
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
46e6e95
initial field built
matthewdylan Oct 25, 2023
2e8e6fe
first run with google automcomplete
matthewdylan Oct 30, 2023
9224106
comment out ref
matthewdylan Oct 30, 2023
fcbc2d2
attempting to update vue-loader
matthewdylan Oct 30, 2023
43d8ec5
Oh, probably importing wrong
matthewdylan Oct 30, 2023
1f941ca
Update config.common.js
matthewdylan Nov 1, 2023
871dba4
autocomplete working now
matthewdylan Nov 2, 2023
dc1b192
updating incorrect v-on usage
matthewdylan Nov 8, 2023
f34b2d9
attempt address field update
matthewdylan Nov 8, 2023
b7466a0
let's see what we're getting
matthewdylan Nov 8, 2023
09838d6
should at least log now
matthewdylan Nov 8, 2023
d832fcd
any luck with a computed value
matthewdylan Nov 9, 2023
5965e31
trying updateValue mixin
matthewdylan Nov 9, 2023
628995f
adding city and state
matthewdylan Nov 9, 2023
0d193e1
Revert "adding city and state"
matthewdylan Nov 9, 2023
6582d9e
adding city to donate form
matthewdylan Nov 9, 2023
67b7e80
push updates to city
matthewdylan Nov 9, 2023
bd19121
re-adding all the city/zipcode updates and the state pieces
matthewdylan Nov 9, 2023
bcaa8c8
updating clases
matthewdylan Nov 16, 2023
46b4129
another try at classes
matthewdylan Nov 16, 2023
5a12061
testing a combined field that has input and does the lookup
matthewdylan Nov 16, 2023
f9617c2
Merge branch 'master' into add-address-lookup
matthewdylan Nov 17, 2023
12a9e61
Some clean-up
matthewdylan Nov 17, 2023
93887f6
Revert "attempting to update vue-loader"
matthewdylan Nov 17, 2023
d949d2e
trying with exclude node_modules real quick
matthewdylan Nov 17, 2023
196e301
attempt implementing autocomplete with Vue.use
matthewdylan Nov 17, 2023
799538e
Revert "attempt implementing autocomplete with Vue.use"
matthewdylan Nov 17, 2023
50b388d
Revert "trying with exclude node_modules real quick"
matthewdylan Nov 17, 2023
d7a6769
more cleanup
matthewdylan Nov 17, 2023
b8845f7
include explicit vol removal
matthewdylan Nov 20, 2023
1ad19cc
Design updates to address fields
matthewdylan Nov 29, 2023
bd34890
trying to swap back after focus
matthewdylan Nov 29, 2023
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ nuclear:
-docker rm -vf $$(docker ps -a -q)
-docker rmi -f $$(docker images -a -q)
-docker system prune -af --volumes
-docker volume rm donations_checkout_node_modules-vol

# original commands
interactive: build backing
Expand Down
32 changes: 31 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"vee-validate": "^3.2.1",
"vue": "^2.7.0",
"vue-clipboard2": "^0.3.0",
"vue-google-autocomplete": "^1.1.4",
"vue-js-modal": "^2.0.1",
"vue-loader": "^15.7.0",
"vue-router": "^3.5.2",
Expand Down
1 change: 1 addition & 0 deletions server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ def donate_form():
bundles=bundles,
stripe=app.config["STRIPE_KEYS"]["publishable_key"],
recaptcha=app.config["RECAPTCHA_KEYS"]["site_key"],
autocomplete=app.config["ADDRESS_AUTOCOMPLETE_KEY"],
use_thermometer=USE_THERMOMETER,
)

Expand Down
5 changes: 5 additions & 0 deletions server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,8 @@ def bool_env(val):
BAD_ACTOR_API_URL = os.getenv("BAD_ACTOR_API_URL", None)
BAD_ACTOR_NOTIFICATION_URL = os.getenv("BAD_ACTOR_NOTIFICATION_URL", None)
BLOCK_LIST = os.getenv("BLOCK_LIST", None)

########
# Google APIs
#
ADDRESS_AUTOCOMPLETE_KEY = os.getenv("ADDRESS_AUTOCOMPLETE_KEY", None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): Would it make sense to add this to the env list table in the readme?

3 changes: 3 additions & 0 deletions server/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class DonateForm(BaseForm):
u"Installment Period", [validators.AnyOf(["yearly", "monthly", "None"])]
)
zipcode = StringField(u"ZIP Code", [validators.Length(max=5)])
address = StringField(u"Address")
city = StringField(u"City")
state = StringField(u"State")


class CircleForm(BaseForm):
Expand Down
85 changes: 82 additions & 3 deletions server/static/js/src/entry/donate/TopForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,53 @@
</div>
</div>

<div class="grid_row grid_separator">
<div class="col">
<div class="form__text form__text--standard">
<label>Address Lookup</label>
<vue-google-autocomplete
id="map"
classname="form-control"
placeholder="Lookup your address"
@placechanged="getAddressData"
>
</vue-google-autocomplete>
</div>
</div>
</div>

<div class="grid_row grid_wrap--s">
<div class="col_6 grid_separator">
<text-input
:store-module="storeModule"
:required="false"
:show-error="showErrors"
label-text="I am giving because"
label-text="address"
base-classes="form__text form__text--standard"
name="reason"
name="address"
/>
</div>
<div class="col_6 grid_separator">
<text-input
:store-module="storeModule"
:required="false"
:show-error="showErrors"
label-text="city"
base-classes="form__text form__text--standard"
name="city"
/>
</div>
</div>

<div class="grid_row grid_wrap--s">
<div class="col_6 grid_separator">
<text-input
:store-module="storeModule"
:required="false"
:show-error="showErrors"
label-text="State"
base-classes="form__text form__text--standard"
name="state"
/>
</div>
<div class="col_6 grid_separator">
Expand All @@ -106,6 +144,19 @@
</div>
</div>

<div class="grid_row grid_separator">
<div class="col">
<text-input
:store-module="storeModule"
:required="false"
:show-error="showErrors"
label-text="I am giving because"
base-classes="form__text form__text--standard"
name="reason"
/>
</div>
</div>

<div class="grid_row grid_separator">
<div class="col">
<pay-fees :store-module="storeModule" base-classes="form__fees" />
Expand All @@ -130,7 +181,8 @@
v-if="nativeIsSupported && showManualPay"
class="grid_separator--l"
aria-hidden="true"
/>
>
</div>

<div
:aria-live="nativeIsSupported ? 'polite' : false"
Expand Down Expand Up @@ -196,6 +248,7 @@
</template>

<script>
import VueGoogleAutocomplete from 'vue-google-autocomplete';
import Hidden from '../../connected-elements/Hidden.vue';
import LocalHidden from '../../local-elements/Hidden.vue';
import Radios from '../../connected-elements/Radios.vue';
Expand All @@ -219,6 +272,7 @@ export default {
ManualPay,
ManualSubmit,
NativePay,
VueGoogleAutocomplete,
},

mixins: [formStarter, updateValue],
Expand All @@ -235,5 +289,30 @@ export default {
],
};
},

methods: {
getAddressData(addressData, placeResultData) {
this.updateValue({
storeModule: this.storeModule,
key: 'address',
value: placeResultData.name,
});
this.updateValue({
storeModule: this.storeModule,
key: 'city',
value: addressData.locality,
});
this.updateValue({
storeModule: this.storeModule,
key: 'state',
value: addressData.administrative_area_level_1
});
this.updateValue({
storeModule: this.storeModule,
key: 'zipcode',
value: addressData.postal_code
});
}
}
};
</script>
18 changes: 18 additions & 0 deletions server/static/js/src/entry/donate/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ export const BASE_FORM_STATE = {
validator: validators.isNotEmpty,
message: 'Enter your last name',
},
address: {
value: '',
isValid: false,
validator: validators.isNotEmpty,
message: 'Enter your address',
},
city: {
value: '',
isValid: false,
validator: validators.isNotEmpty,
message: 'Enter your city',
},
state: {
value: '',
isValid: false,
validator: validators.isNotEmpty,
message: 'Enter your state',
},
reason: {
value: '',
isValid: false,
Expand Down
11 changes: 6 additions & 5 deletions server/templates/donate-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
{% endblock %}

{% block head_scripts %}
{% if form_data and message %}
<script>
window.location.replace('#join-today');
</script>
{% endif %}
<script src="https://maps.googleapis.com/maps/api/js?key={{autocomplete}}&libraries=places"></script>
{% if form_data and message %}
<script>
window.location.replace('#join-today');
</script>
{% endif %}
{% endblock %}

{% block content %}
Expand Down
1 change: 0 additions & 1 deletion webpack/config.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ module.exports = {

{
test: /\.vue$/,
exclude: /node_modules/,
loader: 'vue-loader',
},

Expand Down