From 3f86cbdc9313bbfbf49deab231499b0e096b4351 Mon Sep 17 00:00:00 2001 From: netanelben Date: Mon, 6 Feb 2017 20:28:57 +0200 Subject: [PATCH] published camps & view/edit improve --- config/default.js | 8 +++++--- public/scripts/camps.js | 6 ++++-- routes/api_camps_routes.js | 7 ++++--- views/pages/camps/camp.jade | 6 ++++-- views/pages/camps/edit.jade | 6 ++++-- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/config/default.js b/config/default.js index 15b4baa9c..6c673bdfe 100644 --- a/config/default.js +++ b/config/default.js @@ -2,7 +2,7 @@ const opsworks = require('../opsworks.js'); module.exports = { database: opsworks.db, - + server: opsworks.server, mail: opsworks.mail, @@ -14,12 +14,14 @@ module.exports = { payment: opsworks.payment, npo: opsworks.npo, - + facebook: opsworks.facebook, recaptcha: { sitekey: opsworks.recaptcha.sitekey, secretkey: opsworks.recaptcha.secretkey, ignore: opsworks.recaptcha.ignore - } + }, + + published_camps_origin: 'http://54.194.247.12' }; diff --git a/public/scripts/camps.js b/public/scripts/camps.js index e5a69901d..5f2d7de70 100644 --- a/public/scripts/camps.js +++ b/public/scripts/camps.js @@ -234,7 +234,6 @@ $('.camp_index .join_camp select[name="camp_name_en"]').focus(function() { * Component: View camp details */ function _fetchCampContactPersonDetails() { - var contact_person_id = $('.contact-person').attr('data-camp-contact-person-id'); $.get('/camps_contact_person/' + contact_person_id, function(res) { $('span.contact_person_name').text(res.user.name); $('span.contact_person_phone').text(res.user.phone); @@ -242,7 +241,10 @@ function _fetchCampContactPersonDetails() { }); } if ($('.camps').hasClass('camp_details')) { - _fetchCampContactPersonDetails(); + var contact_person_id = $('.contact-person').attr('data-camp-contact-person-id'); + if (contact_person_id !== "null") { + _fetchCampContactPersonDetails(); + } } /** * Component: Editing camp diff --git a/routes/api_camps_routes.js b/routes/api_camps_routes.js index 90189e269..92ba41f34 100644 --- a/routes/api_camps_routes.js +++ b/routes/api_camps_routes.js @@ -190,7 +190,8 @@ module.exports = function(app, passport) { */ app.get('/camps_published', (req, res, next) => { // Allow this address to http-request to this endpoint. - var API_PUBLISHED_CAMPS_ALLOW_ORIGIN = 'http://10.0.0.12:8080'; + // TODO: add env check - if (app.get('env') === 'development') + var API_PUBLISHED_CAMPS_ALLOW_ORIGIN = config.get('published_camps_origin'); res.header('Access-Control-Allow-Origin', API_PUBLISHED_CAMPS_ALLOW_ORIGIN); res.header('Access-Control-Allow-Methods', 'GET'); @@ -198,7 +199,7 @@ module.exports = function(app, passport) { Camp.fetchAll().then((camp) => { var published_camps = []; for (var i = 0; i < camp.models.length; i++) { - if (camp.models[i].attributes.enabled == '1') { + if (camp.models[i].attributes.enabled == '1' && camp.models[i].attributes.status != 'inactive') { var fetched_camp = { id: camp.models[i].attributes.id, name_en: camp.models[i].attributes.camp_name_en, @@ -230,7 +231,7 @@ module.exports = function(app, passport) { */ app.get('/camps_contact_person/:id', (req, res, next) => { // Allow this address to http-request to this endpoint. - var API_PUBLISHED_CAMPS_ALLOW_ORIGIN = 'http://10.0.0.12:8080'; + var API_PUBLISHED_CAMPS_ALLOW_ORIGIN = config.get('published_camps_origin'); res.header('Access-Control-Allow-Origin', API_PUBLISHED_CAMPS_ALLOW_ORIGIN); res.header('Access-Control-Allow-Methods', 'GET'); diff --git a/views/pages/camps/camp.jade b/views/pages/camps/camp.jade index 086f45146..9439d30fb 100644 --- a/views/pages/camps/camp.jade +++ b/views/pages/camps/camp.jade @@ -20,9 +20,11 @@ block content li.list-group-item span Status if camp.status == 'open' - span.badge.bg__teal Open + span.badge.bg__green Open + if camp.status == 'closed' + span.badge.bg__red Closed else - span.badge.bg__red Close + span.badge.bg__teal Inactive li.list-group-item span Accept Families? span.badge #{camp.accept_families} diff --git a/views/pages/camps/edit.jade b/views/pages/camps/edit.jade index e99945073..eb2111e9a 100644 --- a/views/pages/camps/edit.jade +++ b/views/pages/camps/edit.jade @@ -4,10 +4,12 @@ block content section meta.hidden.meta(id='meta__camp_name_en', value='#{camp.camp_name_en}') .heading.card.card__shad.row - .col-md-12 + .col-xs-12.col-sm-8 h2 #{t('camps:edit.title')}: #{camp.camp_name_en} span.label.label-info #{t('camps:edit.camp')} # #{camp.id} h6 #{t('camps:edit.since')}: #{camp.created_at} + .col-xs-12.col-sm-4 + a.Btn.Btn__sm(href='/#{language}/camps/#{camp.id}') View camp .controls.row .col-xs-12 //- Card switcher @@ -31,7 +33,7 @@ block content label(for='edit_camp_desc_en')=t('camps:edit.desc_en') textarea.form-control(id='edit_camp_desc_en', name='camp_desc_en') #{camp.camp_desc_en} .col-xs-12 - label(for='edit_camp_desc_he')=t('camps:edit.name_he') + label(for='edit_camp_desc_he')=t('camps:edit.desc_he') textarea.form-control(id='edit_camp_desc_he', name='camp_desc_he') #{camp.camp_desc_he} h4=t('camps:edit.website_publication') .camp-publication.panel