Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5387 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php

use LeadersLinked\Model\Network;

$acl            = $this->viewModel()->getRoot()->getVariable('acl');

$currentUser    = $this->currentUserHelper();
$roleName = $currentUser->getUserTypeId();


$this->headLink()->appendStylesheet('/react-bundles/dashboard/main.css');
$this->inlineScript()->appendFile('https://maps.googleapis.com/maps/api/js?key=' . $google_map_key . '&libraries=places');
$currentUser = $this->currentUserHelper();
$currentUser = $currentUser->getUser();

$currentNetwork = $this->currentNetworkHelper();
$currentNetwork = $currentNetwork->getNetwork();


$allowSearchCompany = $acl->isAllowed($roleName, 'search/company') ? 1 : 0;


$allowViewConnectionLevelFilter = $currentNetwork->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER ? 1 : 0;

$routeMoodle = $this->url('moodle');
$emojione_image_path_png  = $this->basePath('vendors/smiley/assets/png/');
$id = $user_uuid ?? null;
$industryFilters = json_encode($industries, true);
$connectionLeves = json_encode($connectionLeves, true);
$_employeeTypes = json_encode($employeeTypes);
$companySizes = json_encode($companySizes, true);
$groupTypes = json_encode($groupTypes, true);
$googleMapPlacesUrl = 'https://maps.googleapis.com/maps/api/js?key=' . $google_map_key . '&libraries=places';
$error_msg = "Por favor seleccione una ubicación real";

$js = <<<JS
const filters = {
  industryFilters: $industryFilters,
  connectionLevelFilters: $connectionLeves,
  employeeTypeFilters: $_employeeTypes,
  companySizeFilters: $companySizes,
  groupTypeFilters: $groupTypes,
  allowSearchCompany: '$allowSearchCompany' === '1',  
  allowViewConnectionLevelFilter:  '$allowViewConnectionLevelFilter' === '1',   
}


const backendVars={
  id: "$id",
  labelSend: "LABEL_SEND",
  labelUsers: "LABEL_USERS",
  labelWriteMessage: "LABEL_WRITE_YOUR_MESSAGE_HERE",
 
}

const LABELS = {
  MY_GROUPS: 'LABEL_MY_GROUPS',
  GROUPS: 'LABEL_GROUPS',
  WHAT_ARE_YOU_THINKING: 'LABEL_WHAT_ARE_YOU_THINKING',
  GROUP_VIEW: 'LABEL_GROUP_VIEW',
  VIEW_MORE: 'LABEL_VIEW_MORE',
  VIEW_LESS: 'LABEL_VIEW_LESS',
  WHO_HAS_SEEN_MY_PROFILE: 'LABEL_WHO_HAS_SEEN_MY_PROFILE',
  CONNECT_WITH: 'LABEL_CONNECT_WITH',
  POSTS: 'LABEL_POSTS',
  DATATABLE_EMPTY: 'LABEL_DATATABLE_EMPTY',
  CONNECT: 'LABEL_CONNECT',
  CANCEL: 'LABEL_CANCEL',
  NOT_AVAILABLE_POSTS: 'LABEL_NOT_AVAILABLE_POSTS',
  MICRO_LEARNING: 'LABEL_MICRO_LEARNING',
  NOT_AVAILABLE_FEEDS: 'LABEL_NOT_AVAILABLE_FEEDS',
  SEND: 'LABEL_SEND',
  SHARE_A_POST: 'LABEL_SHARE_A_POST',
  SHARE_WITH: 'LABEL_SHARE_WITH',
  CONNECTIONS: 'LABEL_CONNECTIONS',
  PUBLIC: 'LABEL_PUBLIC',
  SUGGEST_GROUPS: 'LABEL_SUGGEST_GROUPS',
  VIEW_RECOMMENDATIONS: 'LABEL_VIEW_RECOMMENDATIONS',
  IMAGE: 'LABEL_IMAGE',
  DOCUMENT: 'LABEL_DOCUMENT',
  AUDIO: 'LABEL_AUDIO',
  VIDEO: 'LABEL_VIDEO',
  WRITE_A_POST: 'LABEL_WRITE_A_POST',
  DELETE: 'LABEL_DELETE',
  DOWNLOAD: 'LABEL_DOWNLOAD',
  READ_MORE: 'LABEL_READ_MORE',
  READ_LESS: 'LABEL_READ_LESS',
  LIKE: 'LABEL_LIKE',
  COMMENT: 'LABEL_COMMENT',
  SHARE: 'LABEL_SHARE',
  SHARED: 'LABEL_SHARED',
  COMMENTS: 'LABEL_COMMENTS',
  SENDS: 'LABEL_SENDS',
  WRITE_A_COMMENT: 'LABEL_WRITE_A_COMMENT'
}

function handleScriptLoad(updateQuery, autoCompleteRef, setAddresObject, setError) {
  autoComplete = new window.google.maps.places.Autocomplete(
    autoCompleteRef.current,
    { types: ["(cities)"]}
  );
  autoComplete.setFields(["address_components", "formatted_address", "geometry"]);
  autoComplete.addListener("place_changed", () =>
    handlePlaceSelect(updateQuery, setAddresObject, setError)
  );
}

async function handlePlaceSelect(updateQuery, setAddresObject, setError) {
  const addressObject = autoComplete.getPlace();
  // console.log(addressObject.geometry.location.lat());
  // console.log(addressObject.geometry.location.lng());
  const query = addressObject.formatted_address;
  if(query){
    setError("");
    updateQuery(query);
    setAddresObject({...addressObject, address_components:[...addressObject.address_components, {latitude: addressObject.geometry.location.lat(),longitude: addressObject.geometry.location.lng(), types:["geometry"]}]});
  }else{
    setError("$error_msg");
  }
}

JS;
$this->inlineScript()->appendScript($js);
$this->inlineScript()->appendFile('/react-bundles/search/searchBundle.js');
?>

<div id="react_search" class="posts-section">
  <div class="process-comm" id="paginator-process-comm">
    <div class="spinner">
      <div class="bounce1"></div>
      <div class="bounce2"></div>
      <div class="bounce3"></div>
    </div>
  </div>
</div>