Coder Social home page Coder Social logo

osafw-php's People

Contributors

osalabs avatar vladsavchuk avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

osafw-php's Issues

Naming convention: FwController.php::getListRows()

The intrinsic nature of the getListRows() function is actually to set ($this->list_rows) or even more to init (set multiple properties $this->list_rows, $this->list_pager).

Would it be more clear to have setListRows or initListRows name of this method?

What is "Lookup Manager"?

"Moderator Menu" -> "Lookup Manager"

<li class="nav-item <~/common/active ifeq="GLOBAL[controller]" value="AdminLookupManager">" ><a class="nav-link" href="<~/admin/lookupmanager/url>">Lookup Manager</a></li>

<~/admin/lookupmanager/url> doesn't exist as well as the controller

Best practice: changing layout

I need a custom layout for printing.

Is this the proper approach to change the default layout for Controller?

    public function __construct() {
        parent::__construct();
        $this->fw->page_layout = '/site/layout_print_custom.html';
    }

Best practice: form autosubmit only for selected inputs

I have the form with autosubmit (data-check-changes, data-autosave are set):

image

My question is regarding Birth Date section.
I want to autosubmit only if the all 3 selects are set, or at least if the last Year select is set.

What is the best approach for it? Do we have an inbox solution in fw.js?

Dynamic Controller: Models and Controllers generations

  1. Write permissions is not checked before generation, it should throw the error but the success message is displayed now.
  2. Under Linux I have to fix the ownership of generated files to my local user in order to work with them. And also all files are created with 644 mode. If they were created with 664, I could add myself to the webserver group and edit them without manually fixing permissions.

Dynamic Control: attrs_control

How to use it properly?

"attrs_control": "data-live-search='true" results to the following html:
data-live-search=&quot;true&quot;

"attrs_control": "data-live-search=true" results to the following html:
data-live-search=true

The last one works but I want it to be pretty in html:
data-live-search="true"

Should the attrs_control be default with noescape attibute?
<~attrs_control noescape>

HTML lang attribute

At the moment it is hardcoded to 'en', i.e. does not depend on actual $_SESSION['lang'] value:

<html lang="en" ...

$list_sortdef : order by several columns

It would be nice to order by arbitrary number of columns in lists utilizing default $list_sortdef

public $list_sortdef = 'id asc, title desc, othercolumn';

Currently we need to override setListSorting():

public function setListSorting() {
    if ( $this->list_filter['sortby'] == '') {
        $this->list_orderby = $this->list_sortdef;
    } else {
        parent::setListSorting();
    }
}

Dynamic Controller: list, search filter placeholder

It would be nice to have the ability to set a text placeholder for search input box alongside with the "search_fields", i.e.

"search_fields": "id iname suppliers_iname",
"search_placeholder": "ID, Item, Supplier",

or even better, take those text values from "view_list_map"

And then display this placeholder in search input list filter

Naming convention: ControllerAction(form_id)

Why form_id and not just id?

public function SaveAction($id) {
        $id += 0;
  • form_id is associated with DOM ID like <form id="someDocumentID" ...
  • id is associated with existing entity for the current controller/model, it's like this keyword

Consider the following request:

http://osafw.com/Manage/Bookings/555

It means that some Controller performs Mange action on Booking entity with number-like ID 555 . But the Booking page may have several forms with string-like DOM IDs ("bookingForm", "smsForm", "emalForm" etc) .

sidebar.html: 'access_level' blocks

Suggest changing ifgt to ifge in sidebar.html:

old

<~admin80_menu ifgt="SESSION[access_level]" value="80" inline>

new

<~admin80_menu ifge="SESSION[access_level]" value="80" inline>

Because it's natural to count by tens. Consider the following:

Value Category
100 Admin
90 Supervisor
80 Manger

To display manager menu, I have to
<~admin80_menu ifgt="SESSION[access_level]" value="79" inline>

that doesn't align with having access_level value of 80 in tag name <~admin80 and comparison value of 79.

Font size looks a bit large on mobile devices

Propose to decrease in site.css

If the default size is 16px (common setting in modern browsers), then the reduced size will be 14px:

@media (max-width: 767px) {
  html {
    font-size: 0.875rem;
  }

  .h1, h1 {
    font-size: 2rem;
  }

  .h2, h2 {
    font-size: 1.75rem;
  }

  .h3, h3 {
    font-size: 1.5rem;
  }

  .h4, h4 {
    font-size: 1.5rem;
  }
}

Best practice: JS vars default values for unset PS

Consider the following code in onload.js:

var Config = {
  maxSmsChars: <~js[maxSmsChars]>,
  maxEmailChars: <~js[maxEmailChars]>,
  commsSmsRefreshStatusUrl: '<~/comms/sms/url>' + '/(RefreshSmsStatus)/',
  manageBookingsUrl: '<~/manage/bookings/url>'
}

$PS['js'] array only exists for edit action (existing entity with id), i.e. if it's not new.
So, if I request new action the $PS['js'] is empty and the browser throw JS-syntax error.

What is the best way to deal with this?

Option 1:

var Config = {
  maxSmsChars: <~js[maxSmsChars]><~un_js unless="js[maxSmsChars]" inline>1</~un_js>,
  maxEmailChars: <~js[maxEmailChars]><~un_js2 unless="js[maxEmailChars]" inline>1</~un_js2>,
  commsSmsRefreshStatusUrl: '<~/comms/sms/url>' + '/(RefreshSmsStatus)/',
  manageBookingsUrl: '<~/manage/bookings/url>'
}

Option 2:

var Config = {
  <if_id if="id" inline>
  maxSmsChars: <~js[maxSmsChars]>,
  maxEmailChars: <~js[maxEmailChars]>,
  </if_id>
  commsSmsRefreshStatusUrl: '<~/comms/sms/url>' + '/(RefreshSmsStatus)/',
  manageBookingsUrl: '<~/manage/bookings/url>'
}

Changes in the controller are undesirable for various reasons.

We need a good standard regarding exchanging data between back-end Controller and front-end Client. Probably using some common object in PS with initialization to setup default values.

At the moment it feels strange to me of using ParsePage tags in JS-files ... These tags break syntax highlighting and create linter errors in IDE.

Best practice: PJAX and $ps['_layout']

  1. Should I use the $ps['_layout'] to override the default layout?
  2. Is $ps['_layout'] undocumented feature or hack?
  3. Perhaps it'd be better to use some FW prefix for such kind of overrides, like $ps['_fw_layout'].

Use Case

I have an AJAX-request to get a list of <option>s for the <select>ed value.
I don't want to use default layout_pjax.html because of extra <script> block and the content of `<~main> is escaped by default.

So, I've created /site/layout_pjax_nojs_noescape.html with the following content:

<~main noescape>

And then in the Controller:

public function getSelectOptionsAction() {
    $ps = array(
        '_layout' => '/site/layout_pjax_nojs_noescape.html',
        'main' => $this->model->getSelectOptions(reqs('parent_id'))
    );

    return $ps;
}

Or should I just simply do:

function getSelectOptionsAction() {
    echo $this->model->getSelectOptions(reqs('parent_id'));
}

Dynamic controller: labels noescape

Is there any way to put &HTML; in a label without escaping the ampersand?
I need to add currency sign to label, i.e.

"label", "Price, &euro;"

Proper place for site-wide JS file

I've created site.js to implement instant language switching through AJAX-request and location reload.
I need this JS-file on every page, so I added to the /layout/sys_footer.html the following:

<script src="<~ROOT_URL>/js/site/site.js"></script>

Should we provide empty site.js and recommend to use it like site.css?
I definitely don't want to add site-specific code into fw.js.

DATE/TIME format settings

Should we have these settings in config.site.php instead of class DateUtils static properties definition? I was confused by the default USA format.

Documentation: Routing

I need a comprehensive description about routing.

Probably a two-column table like 'HTTP_METHOD/URL_PATH ---> Corresponding handler in Controller (function name of the action)'.

I'm still confused about const route_default_action = '', and why the values are in lowercase ('index', 'show') when the function names are capitalized ('IndexAction', 'ShowAction') ...

SQL formatting convetion: UPPERCASE

Should we UPPERCASE all SQL key words in code? SELECT, WHERE, ORDER BY etc.

$row = $this->db->row("select * from ".$this->table_name." where id=".$this->db->quote($id));
$row = $this->db->row("SELECT * FROM ".$this->table_name." WHERE id=".$this->db->quote($id));
$sql = "select {$sql_select} where {$sql_where} group by {$sql_group} order by {$sql_order}";
$sql = "SELECT {$sql_select} WHERE {$sql_where} GROUP BY {$sql_group} ORDER BY {$sql_order}";

I find UPPERCASE formatting is more readable especially with huge queries.
It's also better when reading logs in terminal without any highlighting:

select lcc.*, c.iname as 'contacts.iname', c.status as 'contacts.status',
ca.iname as 'cars.iname', ca.iyear as 'cars.iyear', ca.licenseno as 'cars.licenseno', ca.status as 'cars.status'
from link_cars_contacts lcc
left join contacts c on c.id = lcc.contacts_id
left join cars ca on ca.id = lcc.cars_id
where lcc.cars_id='473'
order by lcc.itype
SELECT lcc.*, c.iname AS 'contacts.iname', c.status AS 'contacts.status',
ca.iname AS 'cars.iname', ca.iyear AS 'cars.iyear', ca.licenseno AS 'cars.licenseno', ca.status AS 'cars.status'
FROM link_cars_contacts lcc
LEFT JOIN contacts c ON c.id = lcc.contacts_id
LEFT JOIN cars ca ON ca.id = lcc.cars_id
WHERE lcc.cars_id='473'
ORDER BY lcc.itype

Best practice: implement JSON API

If I want to implement some API-service that talks only in JSON format.
What would be the best approach?

  1. Is it good to put $this->fw->route->format = 'json'; into __construct for every Controller?
  2. If I have a lot of custom actions in some Controller how to avoid setting _json => true for every $ps returned? Create some private function postActionAlterPs(&$ps)or global one in SiteUtils and pass $ps to it in every action?
  3. Or just create base JSON Controller class that extends FwController and then inherit from it?

I think we need some basic guides describing how to do common things.

EU/US date/time format

Currently, to switch to EU date format you need to modify the code in 3 places. Some better one-place setting would be nice.

  1. /template/common/calendar.html, line 5:
        $('.date').datepicker({format: 'dd/mm/yyyy'});
  1. /php/fw/DateUtils.php, lines 8-12
    public static $DATE_FORMAT=0;  
    public static $DATE_FORMAT_STR='DD/MM/YYYY';
    public static $TIME_FORMAT=0;
    public static $TIME_FORMAT_STR='HH:MM';
  1. /php/fw/parsepage.php, line 924, function sec2date. Change "d" and "m" order in the switch block:
  switch (strtolower($format)) {
    case '':
      $format = 'd/m/Y';
      break;
    case 'short':
      $format = 'd/m/Y H:i';
      break;
    case 'long':
      $format = 'd/m/Y H:i:s';
      break;
    case 'sql':
      $format = 'Y-m-d H:i:s';
      break;
  }

IS_LANG_UPD && trailing spaces

If I have trailing spaces inside backticks of multi-language string, the lang file continues to be updated on every request:

`Space trailing `
` Space leading`
` Space both `

en.txt keeps growing with:

Space trailing  ===.
 Space leading ===.
 Space both  ===.
Space trailing  ===.
 Space both  ===.
Space trailing  ===.
 Space both  ===.
Space trailing  ===.
 Space both  ===.
Space trailing  ===.
 Space both  ===.
Space trailing  ===.
 Space both  ===.
Space trailing  ===.
 Space both  ===.
Space trailing  ===.
 Space both  ===.
Space trailing  ===.
 Space both  ===.

Establish best practices for modals

  • modals with content loaded by ajax
  • modals should be easy to attach to required page via templates only without need for additional js
  • modals should be able to attached to different pages
    • (if possible) ability to have multiple modals same kind
  • support before/after modal handlers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.