+#new-area-section{background-color:white}#new-area-section .input-container{margin-bottom:0;padding:0 10px 0 10px}#new-area-section .input-container input.area-name{margin:10px 10px 0 10px}#new-area-section .map-page-selection .select-wrapper .dropdown-content.select-dropdown li:not(:first-child){line-height:1;min-height:20px}#new-area-section .map-page-selection .select-wrapper .dropdown-content.select-dropdown li:not(:first-child) span,#new-area-section .map-page-selection .select-wrapper .dropdown-content.select-dropdown li:not(:first-child) a{line-height:1;padding:2px 10px}
+++ /dev/null
-<?php
-
-/**
- * Gaslight Media Members Database
- * Members List Export by AJAX
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @entity glmMembersDatabase
- * @author Chuck Scott <cscott@gaslightmedia.com>
- * @license http://www.gaslightmedia.com Gaslightmedia
- * @version 0.1
- */
-require_once GLM_MEMBERS_COUNTY_MAP_PLUGIN_CLASS_PATH.'/data/dataMapSettings.php';
-/**
- *
- * This class exports the currently selected members list
- * to a printable HTML file, to a CSV file, or otherwise.
- */
-class GlmMembersAdmin_ajax_mapSettings extends GlmDataMapSettings
-{
-
- /**
- * WordPress Database Object
- *
- * @var $wpdb
- * @access public
- */
- public $wpdb;
- /**
- * Plugin Configuration Data
- *
- * @var $config
- * @access public
- */
- public $config;
-
- /**
- * Constructor
- *
- * This constructor sets up this model. At this time that only includes
- * storing away the WordPress data object.
- *
- * @return object Class object
- *
- */
- public function __construct ($wpdb, $config)
- {
-
- // Save WordPress Database object
- $this->wpdb = $wpdb;
-
- // Save plugin configuration object
- $this->config = $config;
-
- //parent::__construct(false, false);
-
- }
- function write_log ( $log ) {
- if ( true === WP_DEBUG ) {
- if ( is_array( $log ) || is_object( $log ) ) {
- error_log( print_r( $log, true ) );
- } else {
- error_log( $log );
- }
- }
- }
- /**
- * Perform Model Action
- *
- * This modelAction takes an AJAX image upload and stores the image in the
- * media/images directory of the plugin.
- *
- * This model action does not return, it simply does it's work then calls die();
- *
- * @param $actionData
- *
- * Echos JSON string as response and does not return
- */
- public function modelAction ($actionData = false)
- {
- global $wpdb;
- $option = filter_var($_REQUEST['option'], FILTER_SANITIZE_STRING);
- $numbObits = 0;
- $namesList = false;
- $areas = false;
- $test = "testa";
- // Check if an ID is supplied
- $id = 0;
- if ( isset( $_REQUEST['id'] ) ) {
- $id = $_REQUEST['id'] - 0;
- }
- // If there's an action option
- if ( $option ) {
- switch( $option ) {
-
- case 'add':
- $return = $this->insertEntry();
- $id = $return['fieldData']['id'];
- break;
-
- case 'update':
- if ( $id > 0 ) {
- $this->updateEntry( $id );
- }
- break;
-
- case 'delete':
- if ( $id > 0 ) {
- $this->deleteEntry( $id, true );
- }
- break;
-
- case 'list':
- $areas = $this->getList();
- break;
-
- default:
- $option2 = false;
- break;
-
- }
- }
- $data['list'] = $areas;
- $data['test'] = $test;
- // Get number of obits
-
-
- $return = array(
- 'searchData' => $data // Where our events list will go
- );
-
- header('Content-type:application/json;charset=utf-8', true);
- echo json_encode($return);
- wp_die();
- }
-}
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Members List Export by AJAX
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @entity glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+require_once GLM_MEMBERS_COUNTY_MAP_PLUGIN_CLASS_PATH.'/data/dataMapSettings.php';
+/**
+ *
+ * This class exports the currently selected members list
+ * to a printable HTML file, to a CSV file, or otherwise.
+ */
+class GlmMembersAdmin_ajax_mapSettingsAjax extends GlmDataMapSettings
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /**
+ * Constructor
+ *
+ * This constructor sets up this model. At this time that only includes
+ * storing away the WordPress data object.
+ *
+ * @return object Class object
+ *
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ //parent::__construct(false, false);
+
+ }
+ function write_log ( $log ) {
+ if ( true === WP_DEBUG ) {
+ if ( is_array( $log ) || is_object( $log ) ) {
+ error_log( print_r( $log, true ) );
+ } else {
+ error_log( $log );
+ }
+ }
+ }
+ /**
+ * Perform Model Action
+ *
+ * This modelAction takes an AJAX image upload and stores the image in the
+ * media/images directory of the plugin.
+ *
+ * This model action does not return, it simply does it's work then calls die();
+ *
+ * @param $actionData
+ *
+ * Echos JSON string as response and does not return
+ */
+ public function modelAction ($actionData = false)
+ {
+ global $wpdb;
+ $option = filter_var($_REQUEST['option'], FILTER_SANITIZE_STRING);
+ $numbObits = 0;
+ $namesList = false;
+ $areas = false;
+ $test = "start";
+ // Check if an ID is supplied
+ $id = 0;
+ if ( isset( $_REQUEST['id'] ) ) {
+ $id = $_REQUEST['id'] - 0;
+ }
+ // If there's an action option
+ if ( $option ) {
+ switch( $option ) {
+
+ case 'add':
+ $return = $this->insertEntry();
+ $id = $return['fieldData']['id'];
+ break;
+
+ case 'update':
+ if ( $id > 0 ) {
+ $this->updateEntry( $id );
+ }
+ break;
+
+ case 'delete':
+ if ( $id > 0 ) {
+ $this->deleteEntry( $id, true );
+ }
+ break;
+
+ case 'list':
+ $areas = $this->getList();
+ break;
+
+ default:
+ $option2 = false;
+ break;
+
+ }
+ }
+ $data['list'] = $areas;
+ $data['test'] = $this->wpdb->insert_id;
+ // Get number of obits
+
+
+ $return = array(
+ 'searchData' => $data // Where our events list will go
+ );
+
+ header('Content-type:application/json;charset=utf-8', true);
+ echo json_encode($return);
+ wp_die();
+ }
+}
*/
public function modelAction ($actionData = false)
{
- $success = true;
- $areas = false;
-
+
// Enqueue Materialize
wp_register_script(
'materialize',
GLM_MEMBERS_PLUGIN_URL . 'js/materialize/materialize.min.js',
array(
- 'jquery'
+ 'jquery'
),
GLM_MEMBERS_PLUGIN_VERSION
);
-
+ $args = array(
+ 'sort_order' => 'asc',
+ 'sort_column' => 'post_title',
+ 'hierarchical' => 0,
+ 'post_type' => 'page',
+ 'post_status' => 'publish'
+ );
+ $pages = get_pages($args);
wp_enqueue_script('materialize', false, array('jquery'), false, true);
wp_enqueue_style('materialize-css', GLM_MEMBERS_PLUGIN_URL . 'css/materialize.min.css');
wp_enqueue_style('admin-css', GLM_MEMBERS_COUNTY_MAP_PLUGIN_URL . 'css/admin.min.css');
wp_enqueue_style('css-icons', "https://fonts.googleapis.com/icon?family=Material+Icons");
-
- // Model Logic
- $number_of_areas = 0;
- $areaList = false;
-
- // Check if an ID is supplied
- $id = 0;
- if ( isset( $_REQUEST['id'] ) ) {
- $id = $_REQUEST['id'] - 0;
- }
- // If there's an action option
- if ( isset( $_REQUEST['option'] ) ) {
- switch( $_REQUEST['option'] ) {
-
- case 'addNew':
- $return = $this->insertEntry();
- $id = $return['fieldData']['id'];
- break;
-
- case 'update':
- if ( $id > 0 ) {
- $this->updateEntry( $id );
- }
- echo "no id";
- break;
-
- case 'delete':
- if ( $id > 0 ) {
- $this->deleteEntry( $id, true );
- }
- break;
-
- default:
- $option2 = false;
- break;
-
- }
- }
-
- $areas = $this->getList();
-
-
// Compile template data
$templateData = array(
-
+ 'pages' => $pages
);
// Return status, suggested view, and data to controller
+#new-area-section{
+ background-color: white;
+ .input-container{
+ margin-bottom: 0;
+ padding: 0 10px 0 10px;
+ input.area-name{
+ margin: 10px 10px 0 10px;
+ }
+ }
+ .map-page-selection{
+ .select-wrapper{
+ .dropdown-content.select-dropdown{
+ li:not(:first-child){
+ line-height: 1;
+ min-height: 20px;
+ span,a{
+ line-height: 1;
+ padding: 2px 10px;
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
$glmMembersCountyMapAddOnValidActions = array(
'adminActions' => array(
'ajax' => array(
- 'mapSettings' => GLM_MEMBERS_COUNTY_MAP_PLUGIN_SLUG,
+ 'mapSettingsAjax' => GLM_MEMBERS_COUNTY_MAP_PLUGIN_SLUG,
),
'settings' => array(
'mapSettings' => GLM_MEMBERS_COUNTY_MAP_PLUGIN_SLUG,
<button class="btn" data-action="add">Add Area</button>
-<div id="area-section">
-
+<div id="new-area-section">
+ <div class="row input-container">
+ <input class="s12 m6 l3 col area-name" type="text" value="" placeholder="Area Name">
+ </div>
+ <div class="row input-container">
+ <div class="input-field col s12 m6 l3 map-page-selection">
+ <select>
+ <option class="select-placeholder" value="">Select a page</option>
+ {foreach $pages as $page}
+ <option class="map-page-option" value="{$page->ID}">{$page->post_title}</option>
+ {/foreach}
+ </select>
+ </div>
+ </div>
</div>
-<div id="area-list">
+<div id="area-list"></div>
-</div>
<script>
jQuery(function($){
+ let firstRecord = true;
let data = {
action : 'glm_members_admin_ajax',
- glm_action : 'mapSettings',
+ glm_action : 'mapSettingsAjax',
}
// Helper Functions
function serverCall(data){
url: '{$ajaxUrl}',
data: data,
success: function(data) {
- console.log(data.searchData);
- if(data.searchData){
-
- {literal} {/literal}
- }
+ console.log(data);
+ if(!data.list) firstRecord = false;
}
});
};
- function createArea(){
- var row = $("<div class='row'></div>");
-
- var name_input = $("<input>", {
- type: 'text',
- class: "s12 m6 l3 col name-input",
- placeHolder : "Area Name",
- name : 'area_name'
- })
- console.log(name_input.appendTo( $("<div class='s12 col'></div>") ).appendTo(row));
-
- var lat = $("<input>", {
- type: 'text',
- class: "s12 m6 l3 col lat-input inline",
- placeHolder : "lat",
- name : 'lat'
- }).appendTo(row);
-
- var lng = $("<input>", {
- type: 'text',
- class: "s12 m6 l3 col lng-input inline",
- placeHolder : "long",
- name : 'lng'
- }).appendTo(row);
+ function createAreaRecord(){
- var lng = $("<input>", {
- type: 'color',
- class: "s12 m6 l3 col color-input block",
- placeHolder : "Area Name",
- name : 'hover_color'
- }).appendTo(row);
-
- var page = $("<input>", {
- type: 'select',
- class: "s12 m6 l3 col color-input block",
- name : 'page_id'
- }).appendTo(row);
-
- row.appendTo( $("#area-section"))
}
// Form interaction events
$('button').on("click", function(){
- createArea();
+ createAreaRecord();
// data.option = $(this).data("action");
// serverCall(data);
});
-
+ $('select').formSelect();
// Initial page load list population
(function(){
data.option = 'list';