From: Anthony Talarico Date: Mon, 18 Sep 2017 12:45:00 +0000 (-0400) Subject: adding gulp support for sass, fixing the member locked updating X-Git-Tag: v1.0.0~1^2~33 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=2462d50488ade753bc7702bdd58d4e242c134995;p=WP-Plugins%2Fglm-member-db-jobs.git adding gulp support for sass, fixing the member locked updating job postings weren't updating if they were locked to member, fixed that issue. added gulp so the output could be styled with sass --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/classes/data/dataJobTitles.php b/classes/data/dataJobTitles.php index fb21aa2..a1fc9e6 100644 --- a/classes/data/dataJobTitles.php +++ b/classes/data/dataJobTitles.php @@ -161,7 +161,51 @@ class GlmDataJobTitles extends GlmDataAbstract { return $r; } + /** + * Add a job title to the job title table. + * + * This function is provided so cities may be added by other code instead of as a user submission. + * + * @param string $jobTitle Name Name of the job title to add + * + * @return integer ID of the job title just added, the id of an existing record matching the job title name, or false + * + * @access public + */ -} + public function addJobTitles($jobTitleName) { + + // Check that we have a good name + $jName = trim($jobTitleName); + if ($jName == '') { + return false; + } + + // Check if the job title name already exists + $sql = " + SELECT id + FROM ".GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX."job_titles + WHERE job_title = '$jName' + ;"; + $jFound = $this->wpdb->get_row($sql, ARRAY_A); + + // If it already exists, then just retun the id for the existing entry. + if (count($jFound) > 0) { + return $jFound['id']; + } + + // Try to add the job title name + $sql = " + INSERT INTO ".GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX."job_titles + ( job_title ) + VALUES + ( '$jName' ) + ;"; + $this->wpdb->query($sql); + $id = $this->wpdb->insert_id; + // Return the new job title id or false if the query failed + return $id; + } +} ?> \ No newline at end of file diff --git a/css/admin.css b/css/admin.css index d6e341d..4bf34df 100644 --- a/css/admin.css +++ b/css/admin.css @@ -1,43 +1,3 @@ -#glm-admin-content-container .admin-job-label, -#glm-admin-content-container .admin-job-input, -#glm-admin-content-container .admin-job-list{ - padding: 0; -} -.jobTitle-record{ - float: left; -} -.admin-job-input textarea{ - -} -.admin-new-job{ - margin-bottom: 15px; -} -.admin-new-job .admin-new-job-link{ - padding: 5px; - background: #3D84D0; - color: white; - text-decoration: none; - border-radius: 4px; -} -.no-padding{ - padding: 0; -} -.no-margin{ - margin: 0; -} -#glm-admin-content-container .admin-job-list-header{ - margin-bottom: 20px; - padding-bottom: 2px; - border-bottom: 1px solid lightgray; -} -.admin-job-list-row{ - padding-bottom: 5px; -/* border-bottom: 1px solid lightgray;*/ -} -.job-company-list-header,.job-date-list-header, .job-title-list-header{ - font-weight: bold; - font-size: 16px; -} -.admin-job-list-row:nth-child(odd){ - background: #e3e3e5; -} \ No newline at end of file +#glm-admin-content-container .admin-job-label,#glm-admin-content-container .admin-job-input,#glm-admin-content-container .admin-job-list{padding:0}.jobTitle-record{float:left}.admin-new-job{margin-bottom:15px}.admin-new-job .admin-new-job-link{padding:5px;background:#3D84D0;color:white;text-decoration:none;border-radius:4px}.no-padding{padding:0}.no-margin{margin:0}#glm-admin-content-container .admin-job-list-header{margin-bottom:20px;padding-bottom:2px;border-bottom:1px solid lightgray}.admin-job-list-row{padding-bottom:5px}.job-company-list-header,.job-date-list-header,.job-title-list-header{font-weight:bold;font-size:16px}.admin-job-list-row:nth-child(odd){background:#e3e3e5} + +/*# sourceMappingURL=admin.css.map */ diff --git a/css/admin.css.map b/css/admin.css.map new file mode 100644 index 0000000..9499d0f --- /dev/null +++ b/css/admin.css.map @@ -0,0 +1 @@ +{"version":3,"file":"admin.css","sources":["admin.scss"],"sourcesContent":["#glm-admin-content-container .admin-job-label,\n#glm-admin-content-container .admin-job-input,\n#glm-admin-content-container .admin-job-list{\n padding: 0;\n}\n.jobTitle-record{\n float: left;\n}\n.admin-job-input textarea{\n \n}\n.admin-new-job{\n margin-bottom: 15px;\n}\n.admin-new-job .admin-new-job-link{\n padding: 5px;\n background: #3D84D0;\n color: white;\n text-decoration: none;\n border-radius: 4px;\n}\n.no-padding{\n padding: 0;\n}\n.no-margin{\n margin: 0;\n}\n#glm-admin-content-container .admin-job-list-header{\n margin-bottom: 20px;\n padding-bottom: 2px;\n border-bottom: 1px solid lightgray;\n}\n.admin-job-list-row{\n padding-bottom: 5px;\n/* border-bottom: 1px solid lightgray;*/\n}\n.job-company-list-header,.job-date-list-header, .job-title-list-header{\n font-weight: bold;\n font-size: 16px;\n}\n.admin-job-list-row:nth-child(odd){\n background: #e3e3e5;\n}\n"],"names":[],"mappings":"AAAA,AAA6B,4BAAD,CAAC,gBAAgB,CAC7C,AAA6B,4BAAD,CAAC,gBAAgB,CAC7C,AAA6B,4BAAD,CAAC,eAAe,AAAA,CACxC,OAAO,CAAE,CAAC,CACb,AACD,AAAA,gBAAgB,AAAA,CACZ,KAAK,CAAE,IAAI,CACd,AAID,AAAA,cAAc,AAAA,CACV,aAAa,CAAE,IAAI,CACtB,AACD,AAAe,cAAD,CAAC,mBAAmB,AAAA,CAC9B,OAAO,CAAE,GAAG,CACZ,UAAU,CAAE,OAAO,CACnB,KAAK,CAAE,KAAK,CACZ,eAAe,CAAE,IAAI,CACrB,aAAa,CAAE,GAAG,CACrB,AACD,AAAA,WAAW,AAAA,CACP,OAAO,CAAE,CAAC,CACb,AACD,AAAA,UAAU,AAAA,CACN,MAAM,CAAE,CAAC,CACZ,AACD,AAA6B,4BAAD,CAAC,sBAAsB,AAAA,CAC/C,aAAa,CAAE,IAAI,CACnB,cAAc,CAAE,GAAG,CACnB,aAAa,CAAE,mBAAmB,CACrC,AACD,AAAA,mBAAmB,AAAA,CACf,cAAc,CAAE,GAAG,CAEtB,AACD,AAAA,wBAAwB,CAAC,AAAA,qBAAqB,CAAE,AAAA,sBAAsB,AAAA,CAClE,WAAW,CAAE,IAAI,CACjB,SAAS,CAAE,IAAI,CAClB,AACD,AAAA,mBAAmB,AAAA,UAAW,CAAA,AAAA,GAAG,CAAC,CAC9B,UAAU,CAAE,OAAO,CACtB"} \ No newline at end of file diff --git a/css/front.css b/css/front.css index 8aa5d3f..9c8b40d 100644 --- a/css/front.css +++ b/css/front.css @@ -1,6 +1,3 @@ -.no-padding{ - padding: 0; -} -.front-job-list-row{ - margin-bottom: 20px; -} \ No newline at end of file +.no-padding{padding:0}.front-job-listings-wrapper{margin-top:20px}.front-job-listings-wrapper .front-job-list-row{margin-bottom:20px}.front-job-listings-wrapper .job-title-search #job_title_dropdown{max-width:450px}.front-job-listings-wrapper .job-title-search .job-title-button{height:39px}.front-job-listings-wrapper .job-title-list span{font-weight:bold;font-size:20px}@media screen and (max-width: 641px){.front-job-listings-wrapper .job-title-button{display:block;max-width:100px;margin:0 auto}.front-job-listings-wrapper .front-job-search{margin-bottom:20px}}@media (min-width: 639px) and (max-width: 1025px){.front-job-listings-wrapper .job-title-button{display:inline-block;margin:0 0 0 10px}}@media (min-width: 1023px){.front-job-listings-wrapper .job-title-button{display:inline-block;margin:0 0 0 10px}} + +/*# sourceMappingURL=front.css.map */ diff --git a/css/front.css.map b/css/front.css.map new file mode 100644 index 0000000..6f2c792 --- /dev/null +++ b/css/front.css.map @@ -0,0 +1 @@ +{"version":3,"file":"front.css","sources":["front.scss"],"sourcesContent":[".no-padding{\n padding: 0;\n}\n\n.front-job-listings-wrapper{\n .front-job-list{\n\n }\n margin-top: 20px;\n\n .front-job-list-row{\n margin-bottom: 20px;\n }\n .job-title-search{\n #job_title_dropdown{\n max-width: 450px;\n }\n .job-title-button{\n height: 39px;\n }\n }\n .job-title-list{\n span{\n font-weight: bold;\n font-size: 20px;\n }\n }\n @media screen and (max-width: 641px){\n .job-title-button{\n display: block;\n max-width: 100px;\n margin: 0 auto;\n }\n .front-job-search{\n margin-bottom: 20px;\n }\n }\n @media (min-width: 639px) and (max-width: 1025px){\n .job-title-button{\n display: inline-block;\n margin: 0 0 0 10px;\n }\n }\n @media (min-width: 1023px){\n .job-title-button{\n display: inline-block;\n margin: 0 0 0 10px;\n } \n }\n}"],"names":[],"mappings":"AAAA,AAAA,WAAW,AAAA,CACP,OAAO,CAAE,CAAC,CACb,AAED,AAAA,2BAA2B,AAAA,CAIvB,UAAU,CAAE,IAAI,CAyCnB,AA7CD,AAMI,2BANuB,CAMvB,mBAAmB,AAAA,CACf,aAAa,CAAE,IAAI,CACtB,AARL,AAUQ,2BAVmB,CASvB,iBAAiB,CACb,mBAAmB,AAAA,CACf,SAAS,CAAE,KAAK,CACnB,AAZT,AAaQ,2BAbmB,CASvB,iBAAiB,CAIb,iBAAiB,AAAA,CACb,MAAM,CAAE,IAAI,CACf,AAfT,AAkBQ,2BAlBmB,CAiBvB,eAAe,CACX,IAAI,AAAA,CACA,WAAW,CAAE,IAAI,CACjB,SAAS,CAAE,IAAI,CAClB,AAEL,MAAM,CAAC,MAAM,MAAM,SAAS,EAAE,KAAK,EAvBvC,AAwBQ,2BAxBmB,CAwBnB,iBAAiB,AAAA,CACb,OAAO,CAAE,KAAK,CACd,SAAS,CAAE,KAAK,CAChB,MAAM,CAAE,MAAM,CACjB,AA5BT,AA6BQ,2BA7BmB,CA6BnB,iBAAiB,AAAA,CACb,aAAa,CAAE,IAAI,CACtB,CAEL,MAAM,EAAE,SAAS,EAAE,KAAK,OAAO,SAAS,EAAE,MAAM,EAjCpD,AAkCQ,2BAlCmB,CAkCnB,iBAAiB,AAAA,CACb,OAAO,CAAE,YAAY,CACrB,MAAM,CAAE,UAAU,CACrB,CAEL,MAAM,EAAE,SAAS,EAAE,MAAM,EAvC7B,AAwCQ,2BAxCmB,CAwCnB,iBAAiB,AAAA,CACb,OAAO,CAAE,YAAY,CACrB,MAAM,CAAE,UAAU,CACrB"} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..4d14218 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,53 @@ +var gulp = require('gulp'); +var rename = require('gulp-rename'); +var sass = require('gulp-sass'); +var maps = require('gulp-sourcemaps'); + +function swallowError (error) { + + // If you want details of the error in the console + console.log(error.toString()) + + this.emit('end') +} + +function swallowError (error) { + + // If you want details of the error in the console + console.log(error.toString()); + + this.emit('end'); +} + +gulp.task('sass_admin', function() { + return gulp.src('scss/admin.scss') + .pipe(maps.init()) + .on('error', swallowError) + .pipe(sass({ + outputStyle: 'compressed' + })).on('error', swallowError) + .pipe(rename('admin.css')) + .pipe(maps.write('.')) + .pipe(gulp.dest('css')); +}); +gulp.task('sass_front', function() { + return gulp.src('scss/front.scss') + .pipe(maps.init()) + .on('error', swallowError) + .pipe(sass({ + outputStyle: 'compressed' + })).on('error', swallowError) + .pipe(rename('front.css')) + .pipe(maps.write('.')) + .pipe(gulp.dest('css')); + }); + +gulp.task('watch', function () { + gulp.watch('scss/**/*.{scss,sass}', ['sass_admin','sass_front']); +}); + +gulp.task('build', ["sass_admin", "sass_front"]); + +gulp.task('runwatch', ["sass_admin", "sass_front"]); + +gulp.task('default', ["runwatch","watch"]); \ No newline at end of file diff --git a/models/admin/jobs/index.php b/models/admin/jobs/index.php index beaab49..cfcb8a1 100644 --- a/models/admin/jobs/index.php +++ b/models/admin/jobs/index.php @@ -55,7 +55,8 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs * * 'view' * - * A suggested view name that the contoller should use instead of the + * A suggested view name that the contoller should us + $this->job_id = $job['e instead of the * default view for this model or false to indicate that the default view * should be used. * @@ -92,7 +93,7 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs $member_list = $members->getList(); $job_titles = new GlmDataJobTitles($this->wpdb,$this->config); - $job_titles = $job_titles->getList(); + $success_message = ""; $haveJob = false; @@ -182,7 +183,7 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs } } - $job_data = $this->getList($where); + // echo '
', print_r($this->getList()), '
'; // echo '
', print_r($_REQUEST), '
'; @@ -190,15 +191,18 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs switch ($option) { case 'add': + $job_titles = $job_titles->getList(); $job = $this->newEntry(); $view_file = 'edit'; - + + $job_data = $this->getList($where); break; case 'insert': + $this->checkNewJobTitles(); $job = $this->insertEntry(); $this->job_id = $job['fieldData']['id']; - + if ($job['status']) { $haveJob = true; $jobAdded = true; @@ -206,6 +210,7 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs // Update created timestamp and name slug for URLs //$this->updateSlug($this->JobID); + $job_titles = $job_titles->getList(); // Get this again so we have the created date $job = $this->editEntry($this->job_id); @@ -216,26 +221,36 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs $option = 'add'; $jobAddError = true; } - + $job_data = $this->getList($where); $view_file = 'edit'; break; case 'edit': + $job = $this->editEntry($this->job_id); + + // If we're locked to a member as a contact user and the event member doesn't equal the contact member + if ($lockedToMember && $job['fieldData']['member']['value'] != $lockedToMember) { + $haveJob = false; + $job = false; + } // If we have a good Job if ($job['status']) { $haveJob = true; } - + $job_titles = $job_titles->getList(); + $job_data = $this->getList($where); $view_file = 'edit'; break; case 'update': + // Try to update this Job $job = $this->updateEntry($this->job_id); - + $this->checkNewJobTitles(); + // Check if that was successful if ($job['status']) { $jobUpdated = true; @@ -245,9 +260,10 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs } else { $jobUpdateError = true; } - - $haveJob = true; - $view_file = 'edit'; + $job_titles = $job_titles->getList(); + $job_data = $this->getList($where); + $haveJob = true; + $view_file = 'edit'; break; @@ -260,6 +276,7 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs $jobDeleteError = true; } $view_file = "index"; + $job_titles = $job_titles->getList(); $job_data = $this->getList(); break; default: @@ -296,4 +313,41 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs 'data' => $templateData ); } + /** + * Check for new Cities being submitted + * + * @return void + */ + public function checkNewJobTitles() + { + + // If we have a member ID and this was a submission with a new city (id < 0) + if (isset($_REQUEST['new_job_title']) && trim($_REQUEST['new_job_title']) != '') { + + // Clean up job titlename + $jName = trim(filter_var($_REQUEST['new_job_title'])); + + // Try to add the job title + require_once GLM_MEMBERS_JOBS_PLUGIN_CLASS_PATH.'/data/dataJobTitles.php'; + $jobTitles = new GlmDataJobTitles($this->wpdb, $this->config); + $jID = $jobTitles->addJobTitles($jName); + + // If we got a job title id back + if (is_int($jID) && $jID > 0) { + + // Update the job title selected for this job record + $sql = " + UPDATE ".GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX."jobs + SET title = $jID + WHERE id = ".$this->job_id." + ;"; + $insert = $this->wpdb->query($sql); + echo $insert; + + // Update submitted job title value to use the new ID + $_REQUEST['new_job_title'] = $jID; + + } + } + } } diff --git a/models/admin/jobs/list.php b/models/admin/jobs/list.php deleted file mode 100644 index 3ac00fa..0000000 --- a/models/admin/jobs/list.php +++ /dev/null @@ -1,8 +0,0 @@ - array( 'jobs' => array( 'index' => GLM_MEMBERS_JOBS_PLUGIN_SLUG, - 'list' => GLM_MEMBERS_JOBS_PLUGIN_SLUG, ), 'settings' => array( 'jobTitles' => GLM_MEMBERS_JOBS_PLUGIN_SLUG, diff --git a/views/admin/jobs/edit.html b/views/admin/jobs/edit.html index 04db4f0..cc5c7de 100644 --- a/views/admin/jobs/edit.html +++ b/views/admin/jobs/edit.html @@ -40,6 +40,7 @@
- + +
@@ -76,7 +78,11 @@ + {else} + + {/if} +
diff --git a/views/front/jobs/list.html b/views/front/jobs/list.html index 12eb564..74e78cb 100644 --- a/views/front/jobs/list.html +++ b/views/front/jobs/list.html @@ -1,40 +1,42 @@ - -{if $jobData} - {foreach $jobData as $key=>$value} -
-
-
-
- {$value.title} -
-
- Location: {$value.job_location} -
-
- Company: {$value.company} -
-
- {$value.post_date.timestamp|date_format:"%Y-%m-%d"} +
+ + {if $jobData} + {foreach $jobData as $key=>$value} +
+
+
+
+ {$value.title} +
+
+ Location: {$value.job_location} +
+
+ Company: {$value.company} +
+
+ {$value.post_date.timestamp|date_format:"%Y-%m-%d"} +
+ Full Job Description
- Full Job Description
+ {/foreach} + {else} +
+
+ No Job Listings
- {/foreach} -{else} -
-
- No Job Listings
+{/if}
-{/if} \ No newline at end of file