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

Development #395

Merged
merged 29 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a07d425
Make it possible to set the href on the counter
LorenzoJokhan Jan 2, 2023
8fc1639
Set counterUrl without lodash lib
LorenzoJokhan Jan 16, 2023
670ae78
Merge pull request #379 from openstad/feature/set-url-on-counter-widget
LorenzoJokhan Jan 16, 2023
b258b97
Add a message when the widget is used on a non-idea resource page and…
LorenzoJokhan Feb 10, 2023
55f1c9a
Made it so the title can be changed of the succesfull voting message
LorenzoJokhan Feb 10, 2023
db8ecf2
Added field to phase-voting-budgeting
LorenzoJokhan Feb 10, 2023
d28a201
Merge pull request #382 from openstad/feature/show-message-on-wrong-u…
LorenzoJokhan Feb 13, 2023
965e33f
Corrected spelling
LorenzoJokhan Feb 13, 2023
e308544
Corrected spelling
LorenzoJokhan Feb 13, 2023
14c18ee
Changed spelling of successful
LorenzoJokhan Feb 13, 2023
a82dd76
Changed spelling of step_3_successful_auth
LorenzoJokhan Feb 13, 2023
1dd2436
changed spelling in label of field
LorenzoJokhan Feb 13, 2023
5c8d931
Merge pull request #384 from openstad/fix/change_step_3_succesfull_au…
LorenzoJokhan Feb 13, 2023
b6a20f9
Merge branch 'development' into feature/edit-succesfull-voting-on-bud…
LorenzoJokhan Feb 13, 2023
db4147b
Merge pull request #383 from openstad/feature/edit-succesfull-voting-…
LorenzoJokhan Feb 13, 2023
c193031
Added message closed but open for admin / editor / moderator
LorenzoJokhan Feb 13, 2023
7a0197b
Update packages/cms/lib/modules/arguments-block-widgets/index.js
LorenzoJokhan Feb 13, 2023
b6f468f
Update packages/cms/lib/modules/arguments-block-widgets/views/widget.…
LorenzoJokhan Feb 13, 2023
cb95a7c
Merge pull request #385 from openstad/feature/show-message-close-argu…
LorenzoJokhan Feb 13, 2023
eb888e9
Aloow for multiple tabs sections on a page
nlsvgtr Feb 21, 2023
b800771
Merge pull request #387 from Amsterdam/codeimprovement/fix-multiple-t…
nlsvgtr Feb 21, 2023
2ec38f9
Make js uglifyable
nlsvgtr Feb 21, 2023
8766fe5
Added fallback text because if you did not commit on a preexisting fo…
LorenzoJokhan Mar 3, 2023
b88c97f
Merge pull request #388 from openstad/add-successfull-voting-fallback…
LorenzoJokhan Mar 3, 2023
8846a68
Feature/group tags like mzm (#386)
LorenzoJokhan Mar 7, 2023
e928524
Bugfix/tags remember choices on edit idea (#389)
LorenzoJokhan Apr 13, 2023
f4cdefd
Merge branch 'master' into development
LorenzoJokhan Apr 20, 2023
9e09f78
make inzendingPath the same as global config > ideaSlug (#392)
LorenzoJokhan Apr 26, 2023
9008256
Changed reading of activeResource param in html (#393)
LorenzoJokhan May 2, 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
4 changes: 3 additions & 1 deletion packages/cms/lib/modules/arguments-block-widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ module.exports = {
const superLoad = self.load;
self.load = function(req, widgets, next) {
widgets.forEach((widget) => {
const data = req.data;

let config = createConfig({
widget: widget,
data: req.data,
data,
});
widget.config = config;
widget.divId = widget.config.divId;
widget.isClosedButRoleAllows = config.isClosed && (data.isAdmin || data.isEditor || data.isModerator);
});

return superLoad(req, widgets, next);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@

<div id="{{data.widget.containerId}}" class="osc-component" style="width: 100%; height: 100%;">

{% if data.activeResource and data.widget.isClosedButRoleAllows %}
<p>Reageren is gesloten, maar je kunt nog reageren vanwege je rol als {{ data.openstadUser.role }}</p>


{% endif %}
{% if data.activeResource and data.activeResource.publishDate %}
<div class="{{data.widget.divId}}" style="width: 100%; height: 100%;"></div>
{% elif (data.isAdmin or data.isEditor or data.isModerator) and data.activeResourceType !== 'idea'%}
<p>Deze widget kan alleen worden gebruikt op pagina`s met een resource waarbij het activeResourceType idea is</p>
{% else %}
<p>Er kunnen geen argumenten worden gegeven op een concept plan</p>
<p>Er kunnen geen argumenten worden gegeven op een concept plan</p>
{% endif %}

</div>
10 changes: 8 additions & 2 deletions packages/cms/lib/modules/begroot-widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,18 @@ const fields = [
def: 'Via onderstaande knop kun je op een aparte pagina je persoonlijke stemcode invullen. Wij controleren de stemcode op geldigheid. Als dat gelukt is kom je terug op deze pagina waarna je kunt stemmen. Alle bewoners van Centrum hebben per post een stemcode ontvangen.'
},
{
name: 'step_3_succesfull_auth',
label: 'Step 3: succesfull auth',
name: 'step_3_successful_auth',
label: 'Step 3: successful auth',
type: 'string',
textarea: true,
def: 'Het controleren van je stemcode is gelukt! Je bent bijna klaar. Klik op onderstaande knop om je stem te versturen.'
},
{
name: 'successful_voting_title',
label: 'Message you see when you voted successfully',
type: 'string',
def: 'Gelukt, je hebt gestemd!'
},
{
name: 'thankyou_message',
label: 'Thank you message',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ <h3 class="icon-header icon-header--blue">
<small>Vul een andere stemcode in</small>
</a>
<div>
{{data.widget.step_3_succesfull_auth}}
{{data.widget.step_3_successful_auth}}
</div>
</div>

Expand Down Expand Up @@ -340,7 +340,7 @@ <h3 class="icon-header icon-header--blue">
</div>
</a>
<div class="mobile-accordion-body">
{{data.widget.step_3_succesfull_auth}}
{{data.widget.step_3_successful_auth}}
</div>
</div>
<br />
Expand All @@ -356,7 +356,7 @@ <h3 class="icon-header icon-header--blue">
<div id="steps-content-6" class="step">
<div class="text">
<div class="checkmark-block-green">
<h4>Gelukt, je hebt gestemd!</h4>
<h4>{{data.widget.successful_voting_title or "Gelukt, je hebt gestemd!"}}</h4>
<br/>
{{data.widget.thankyou_message | sanitize | safe | nlbr}}
{% if data.widget.showNewsletterButton and data.widget.showNewsletterButton == 'yes' %}
Expand Down
10 changes: 9 additions & 1 deletion packages/cms/lib/modules/idea-map-widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ module.exports = {
type: 'string',
label: 'Counter text',
},
{
name: 'counterUrl',
type: 'string',
label: 'Counter url',
def: 'plannen',
required: false
},
{
name: 'useMarkerLinks',
type: 'boolean',
Expand Down Expand Up @@ -115,7 +122,7 @@ module.exports = {
{
name: 'counter',
label: 'Counter',
fields: ['displayCounter', 'counterText']
fields: ['displayCounter', 'counterText', 'counterUrl']
},
{
name: 'content',
Expand Down Expand Up @@ -169,6 +176,7 @@ module.exports = {


widgets.forEach((widget) => {
widget.counterUrl = widget.counterUrl || 'plannen';
widget.ideas = req.data.ideas ? req.data.ideas.map((idea) => {
return {
location: idea.location,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% macro numberPlateButton(name, caption, value, href, color="#004699") %}
{% if href %}
<a href="{{data.siteUrl}}/plannen" class="{{name}}">
<a href="{{data.siteUrl}}/{{href}}" class="{{name}}">
{% else %}
<div class="{{name}}">
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</a>
{% endif %}
{% if (data.widget.displayCounter) %}
{{numberPlateButton.numberPlateButton('no-of-locations', data.widget.counterText, data.ideas.length, '#')}}
{{numberPlateButton.numberPlateButton('no-of-locations', data.widget.counterText, data.ideas.length, data.widget.counterUrl)}}
{% endif %}
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion packages/cms/lib/modules/openstad-api/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ module.exports = (self, options) => {
};

self.updateSiteConfig = async (req, siteConfig, item, apiSyncFields) => {

apiSyncFields.forEach(field => {
if(field.name === 'ideaSlug') {
siteConfig.ideas.feedbackEmail["inzendingPath"] = item.ideaSlug;
siteConfig.ideas.conceptEmail["inzendingPath"] = item.ideaSlug;
siteConfig.ideas.conceptToPublishedEmail["inzendingPath"] = item.ideaSlug;
}
//item is the inter global config
const value = self.getFieldValue(item, field);
self.setApiConfigValue(siteConfig, field.apiSyncField, value);
Expand Down
17 changes: 15 additions & 2 deletions packages/cms/lib/modules/openstad-pages/lib/load-tags.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const rp = require('request-promise');
const _ = require('lodash');
const moment = require('moment'); // returns the new locale, in this case 'de'
const url = require('url');
const internalApiUrl = process.env.INTERNAL_API_URL;
Expand All @@ -17,17 +18,24 @@ module.exports = function (req, res, next) {
*/
if (globalData.siteId) {
let tags;

let retrievedEmpty = false;
// if cacheIdeas is turned on, get ideas from cache
// cacheIdeas is old key, should be refactored,
// preferable we always have caching on

if (globalData.cacheIdeas) {
let cacheKey = 'tags-' + globalData.siteId;
tags = cache.get(cacheKey);
retrievedEmpty = cache.get(globalData.siteId + '-retrieved-tags-empty');
}

if (Array.isArray(tags)) {
req.data.openstadTags = tags;
req.data.groupedOpenstadTags = _.groupBy(tags, function(tag){return tag.type});

next();
} else if(retrievedEmpty) {
req.data.openstadTags = [];
next();
} else {

Expand All @@ -42,9 +50,14 @@ module.exports = function (req, res, next) {
//add tags to to the data object so it's available in templates
//use openstadTags instead of tags to prevent colliding with Apos
req.data.openstadTags = response;
req.data.groupedOpenstadTags = _.groupBy(response, function(tag){return tag.type});

// set the cache
if (globalData.cacheIdeas) {
cache.set(globalData.siteId + '-retrieved-tags-empty', response.length === 0, {
life: cacheLifespan
})

cache.set('tags-' +req.data.global.siteId, response, {
life: cacheLifespan
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
{
name: 'explanation-texts',
label: 'Explanation texts',
fields: ['step_1_intro', 'step_2_intro', 'step_3_intro', 'step_3_succesfull_auth', 'thankyou_message', 'showNewsletterButton', 'newsletterButtonText']
fields: ['step_1_intro', 'step_2_intro', 'step_3_intro', 'step_3_successful_auth','successful_voting_title', 'thankyou_message', 'showNewsletterButton', 'newsletterButtonText']
},
{
name: 'authentication',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,18 @@ const fields = [
def: 'Via onderstaande knop kun je op een aparte pagina je persoonlijke stemcode invullen. Wij controleren de stemcode op geldigheid. Als dat gelukt is kom je terug op deze pagina waarna je kunt stemmen. Alle bewoners van Centrum hebben per post een stemcode ontvangen.'
},
{
name: 'step_3_succesfull_auth',
name: 'step_3_successful_auth',
label: 'Step 3: succesfull auth',
type: 'string',
textarea: true,
def: 'Het controleren van je stemcode is gelukt! Je bent bijna klaar. Klik op onderstaande knop om je stem te versturen.'
},
{
name: 'successful_voting_title',
label: 'Message you see when you voted successfully',
type: 'string',
def: 'Gelukt, je hebt gestemd!'
},
{
name: 'thankyou_message',
label: 'Thank you message',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ <h3 class="icon-header icon-header--blue">
<small>Vul een andere stemcode in</small>
</a>
<div>
{{data.widget.step_3_succesfull_auth}}
{{data.widget.step_3_successful_auth}}
</div>
</div>

Expand Down Expand Up @@ -352,7 +352,7 @@ <h3 class="icon-header icon-header--blue">
</div>
</a>
<div class="mobile-accordion-body">
{{data.widget.step_3_succesfull_auth}}
{{data.widget.step_3_successful_auth}}
</div>
</div>
<br />
Expand All @@ -368,7 +368,7 @@ <h3 class="icon-header icon-header--blue">
<div id="steps-content-6" class="step">
<div class="text">
<div class="checkmark-block-green">
<h4>Gelukt, je hebt gestemd!</h4>
<h4>{{data.widget.successful_voting_title or "Gelukt, je hebt gestemd!"}}</h4>
<br/>
{{data.widget.thankyou_message | sanitize | safe | nlbr}}
{% if data.widget.showNewsletterButton and data.widget.showNewsletterButton == 'yes' %}
Expand Down
6 changes: 6 additions & 0 deletions packages/cms/lib/modules/resource-form-widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ module.exports = {
const isReactedTo = activeResource ? (activeResource.yes > 0 || activeResource.no > 0 || activeResource.argumentCount > 0) : false;
const isOwnerOrAdmin = ((!isReactedTo || !widget.hideAdminAfterPublicAction) && isOwner) || req.data.hasModeratorRights;


widget.isTagSelected = function(tagId) {
if(!activeResource || !Array.isArray(activeResource.tags)) return false;
return activeResource.tags.findIndex(t => t.id === tagId) !== -1;
}

widget.mapConfig = self.getMapConfigBuilder(globalData)
.setDefaultSettings({
mapCenterLat: (activeResource && activeResource.location && activeResource.location.coordinates && activeResource.location.coordinates[0]) || globalData.mapCenterLat,
Expand Down
23 changes: 22 additions & 1 deletion packages/cms/lib/modules/resource-form-widgets/lib/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const fields = [
{
value: 'tags',
label: "Tags (currently only works for ideas)",
showFields: ['fieldKey', 'fieldRequired', 'fieldMin', 'fieldMax']
showFields: ['fieldKey', 'fieldRequired', 'tagType', 'showTagTypeLabels', 'fieldMin', 'fieldMax']
},
{
value: 'raw',
Expand Down Expand Up @@ -296,6 +296,27 @@ const fields = [
type: 'string',
textarea: true
},
{
name: 'tagType',
label: 'Optionally specify the single type (one word) by which to fetch the tags.',
type: 'string'
},
{
name: 'showTagTypeLabels',
label: 'When the above option is empty, select if the corresponding types should be shown or not',
type: 'boolean',
choices: [
{
label: 'Yes',
value: true,
},
{
label: 'No',
value: false,
}
],
def: false
},
{
name: 'notExtraDataKey',
label: 'Save field in root if data object and not in extraData, will only work if column exists in database)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ $(document).ready(function () {

$(form).find('input[type="submit"]').each(function(index, button) {
oldButtonValues.push($(this).val());

if(button.id === "btnSaveAsConcept" && publishField.val()) {
$(this).val('Verzenden...');
} else if(!publishField.val()) {
Expand All @@ -206,6 +205,12 @@ $(document).ready(function () {
success:function(response) {
formHasChanged = false;
var redirect = $(form).find('.form-redirect-uri').val();

// for some reason when you select the dynamic form then the input field with class .form-redirect-uri is not within the form
if(!redirect) {
redirect = document.querySelector('.form-redirect-uri').value;
}

redirect = redirect.replace(':id', response.id);
redirect = window.siteUrl + redirect;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,52 @@
<div class="checkbox-container">
{% for tag in data.openstadTags %}
<div class="checkbox">
<input
type="checkbox"
name="tags[]"
value="{{tag.id}}"
id="checkbox-{{loop.index}}-{{option.value}}"
{% if field.fieldRequired %}required{% endif %}
{% if field.idea.tags %}checked{% endif %}
/>
<label for="checkbox-{{loop.index}}-{{option.value}}" class="checkbox-label">
{{tag.name}}
</label>
{% if field.tagType
and data.groupedOpenstadTags[field.tagType]
and data.groupedOpenstadTags[field.tagType].length %}

{% for tag in data.groupedOpenstadTags[field.tagType] %}
<div class="checkbox">
<input
type="checkbox"
name="tags[]"
value="{{tag.id}}"
id="checkbox-{{loop.index}}-{{tag.id}}"
{% if field.fieldRequired %}required{% endif %}
{% if field.idea.tags %}checked{% endif %}
/>
<label for="checkbox-{{loop.index}}-{{tag.id}}" class="checkbox-label">{{tag.name}}</label>
</div>
{% endfor %}
{% endif %}
</div>


{% if field.tagType === '' or field.tagType === undefined %}
{% for key, tagList in data.groupedOpenstadTags %}
{% set outer_loop = loop %}

{% if field.showTagTypeLabels %}
{% if outer_loop.length > 1 and key !== 'undefined' %}
<p>{{key}}</p>
{% endif %}

{% if outer_loop.length > 1 and key == 'undefined' %}
<p>Overig</p>
{% endif %}
{% endif %}

{% for tag in tagList %}
<div class="checkbox">
<input
type="checkbox"
name="tags[]"
value="{{tag.id}}"
id="checkbox-{{outer_loop.index}}-{{loop.index}}-{{tag.id}}"
{% if field.fieldRequired %}required{% endif %}
{% if data.widget.isTagSelected(tag.id) %}checked{% endif %}
/>
<label for="checkbox-{{outer_loop.index}}-{{loop.index}}-{{tag.id}}" class="checkbox-label">{{tag.name}}</label>
</div>
{% endfor %}
{% endfor %}
{% endif %}
</div>
2 changes: 2 additions & 0 deletions packages/cms/lib/modules/resource-overview-widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ module.exports = {
return Object.assign({}, tag);
}) : [];

widget.groupedOpenstadTags = req.data.groupedOpenstadTags;

let response;

// if cache is turned on, check if current url is available in cache
Expand Down
Loading