Jump to content

bernhard

Members
  • Posts

    6,629
  • Joined

  • Last visited

  • Days Won

    358

Everything posted by bernhard

  1. Hi @LostKobrakai I don't know ? https://mathjs.org/ Could you explain a little more verbose please why you think that parsefloat is a problem? For all my use-cases I can think of, this is exactly the output I want to get...
  2. Ok thx, now I get it ? I've planned that feature, but can't remember that I've ever used it, so I don't know if that still works (see option 2, InputfieldRockGrid.module.php): If you are talking about excel export: yes. I don't have any sample code, see /plugins/buttons/excel.js
  3. Still don't get it. We have forms all over PW (and the web), so it's hard to guess which one you are talking about... and I have also no idea what you mean by using RockGrid "as usual" - but I'm curious: Are you using it on the Frontend?
  4. v0.0.6 adds support for runtime fields, that means you can now use mathparser in your processmodules as well just by specifying one property: /** @var InputfieldDecimal $f */ $f = $this->modules->get('InputfieldDecimal'); $f->label = "foo"; $f->attr('id+name', "bar"); $f->mathParser = true;
  5. Thx for sharing and congratulations for the great site! Interesting approach for the menu! I tested it on mobile and found this little hickup (and spacings could also be removed): Also I'd suggest to list all children at the bottom of those pages: https://mawsonshuts.antarctica.gov.au/preparation/australia-and-antarctica/ (not only next and previous). For me it was not clear that the two links at the bottom belong to one parent (as seen very well in the menu). You can have a look how I did it here: https://www.maletschek.at/segelmacherei/persenning/cockpitpersenning/
  6. @flydev could you please share some screenshots or screencasts? @NorbertH did you try my module? It's exactly built for such backend modifications without having to build a whole new admin theme (and I'd be happy to have a more condensed version as well, but CSS is not my strongest skill):
  7. Sorry, I don't get what you are saying ? BTW: Of course you can just show a simple grid without modifying it via javascript. That's explained in the quickstart: https://github.com/BernhardBaumrock/FieldtypeRockGrid/wiki/Quickstart (actually there is nothing to explain if you don't use any javascript modifications). But as soon as you want to style or tweak your grid (eg custom Headernames) you need javascript. Would be happy to see some screenshots so maybe others do also get inspired by your work ?
  8. Hi @gottberg glad to hear that. Sometimes I feel that the potential of this or similar modules is underestimated. If you only need a HTML grid (table) then you might be better off using MarkupAdminDataTable. RockGrid is by design a grid with user input like filtering and sorting and custom colorizations based on cell values. If you don't need all that just create a plain html table. Does that help?
  9. I found the issue! I'll file a report on github and link it here when I'm done. https://github.com/processwire/processwire-issues/issues/885
  10. public function executeDemo() { $form = $this->modules->get('InputfieldForm'); /** @var InputfieldForm $form */ $tmpDir = $this->files->tempDir('upload_csv'); $f = $this->modules->get('InputfieldFile'); $f->attr('id+name', 'upload_csv'); $f->extensions = 'csv'; $f->maxFiles = 1; $f->descriptionRows = 0; $f->overwrite = true; $f->label = 'Upload CSV yyy'; $f->icon = 'download'; $f->destinationPath = $tmpDir; $f->collapsed = Inputfield::collapsedYesAjax; $form->add($f); return $form->render(); } Simple process module to replicate this issue. Comment the $f->collapsed line and it will work, leave it there and it will upload the file instantly (which is not wanted)
  11. The endpoint for the AJAX request is .../crm/transactions/?InputfieldFileAjax=1 and if I try to open this site in a new tab I get a prompt "does not respond, do you want to wait...?" after some time. But that would be ok for me. Once more: I want the ajax loaded field to behave just like it does when it is non-ajax loaded. The Inputfield changes to "Demo.csv" but the file is NOT uploaded. That's how the field should work on ProcessModules. But it does not work like this when the field is AJAX loaded. Then the field behaves like it was on a regular ProcessPageEdit screen. And I don't know why this is the case. I can't find any differences in the markup or in the code. Edit: Another difference is that the AJAX field shows the drag&drop span while the non-ajax field does NOT show it: I've no idea why that is the case..
  12. What do you mean by "otherwise independent"? It is easy to have two pw instances connecting to one DB (just put the same in config.php), but that makes no sense in a production/dev environment. Adding a field to one site means you'll also have it in your other site. If your code does not reflect that (in BOTH instances), you'll get into trouble (php errors). And you don't want to have those DB changes on the live system instantly of course! Imagine you want to try adding a new "lorem ipsum" news entry... you'll instantly have it on your live system! You have two options: 1) Duplicate your live website to the dev environment, make changes, test everything, push the changes back to live --> this works only if you don't have any changes to the DB on your live system while you are developing/testing on your dev system 2) Migrations https://processwire.com/blog/posts/introduction-migrations-module/ https://weekly.pw/issue/261/#new-module-rockmigrations (thx @teppo for listing it)
  13. Thank you all for you quick answers! Seems that I was unclear about the problem. The main problem is that the Inputfield behaves different wether it is loaded instantly or via AJAX. When loaded directly, the field does NOT upload the file instantly. When loaded via AJAX, the file IS uploaded instantly and throws an error. I'm not trying to find a quick solution, I'm trying to find a universal solution that works in both scenarios (because I'm developing a module that can be used anywhere and anyhow (as AJAX or non-AJAX). So the main problem is that I don't know WHY the field behaves different and so I don't know HOW I can modify this behaviour! I'm a bit confused about this error. The network entry shows an empty 200 return, but when I set a breakpoint the responseText is some RockGrid markup: So this error might have something to do with RockGrid. But I'm not worried about this error because the upload has to fail since there is no page to upload the file to. What I want to achieve is that the field does NOT upload the file instantly and only submits the file on form submit. Just like the PW module installer does. In general yes, but there is a way to upload files via InputfieldFile (see the module installer for example). You just need to set a destinationPath property and you can then process this file. This works just fine when the field is loaded non-ajax. I hope I could explain it a little better now ? Thx for your help!
  14. Hello everyone, I'm having an issue with an ajax loaded file upload field in a processmodule. The file upload field itself works as expected when the field is not ajax loaded (see video): The file is stored as value in the inputfield and will be executed after form submission. But when I load the file upload inputfield in a fieldset that is ajax loaded, the behaviour is different: The file gets uploaded instantly and the JSON return is invalid: Does anybody know how I can modify this behaviour? Actually... the instant ajax upload could be even better for my usecase: Upload the CSV, execute it on the backend, reload the grid with new data (without reloading the page which means I don't lose filters, selections etc). Here is the video demonstrating the issue:
  15. Just had a very interesting conversation with @wbmnfktr and wanted to share this little preview of a quite big upgrade coming soon called "RockGridActions". I'll share some more infos soon. The great thing about it is that it is built modularly so that we'll be able to use it almost plug&play for RockTabulator ( @Beluga)
  16. Hi @Gadgetto, this looks great! I've played around with Snipcart and Foxycart quite a lot and then built my own solution (which was quite a pain as well ? ). Snipcart definitely looked best IMHO but it is also quite expensive. But it may be worth that price if we have a good working module that integrates well and saves us lots of time during development. Well... free sounds great ? No idea how much money one can make by selling a pro module to the community - I've never heard any numbers and there have been several discussions about that. So I'm not even sure if it makes sense at all to sell anything to the pw community. It's also more effort to setup some kind of selling process, api key verificaton etc. (well, maybe not for you now that you can use SnipWire for that ? ); I decided to release RockGrid free for example so that others can use it easily in their modules (didn't happen as far as I know), but I stated that extended support is not for free. But RockGrid is totally different. A shopping cart is of course much more mainstream and has a broader audience for sure. I could be a possible customer one day ?
  17. Thx @horst I know that this is easy to fix, but I don't think that we should have to think about that! The API is there to make things easy and bulletproof. So the problem is that someone might develop a module on a unix system, thinks that everything works properly and then a windows user gets an error because the implementation of converting file paths to relative urls didn't think of that case... Thx for that hint Horst! I've created a new PR that merges to the DEV branch ? https://github.com/processwire/processwire/pull/143 Is your implementation better in any way than my 2 line version? https://github.com/processwire/processwire/pull/143/files (in other words: Did I not think of anything?)
  18. Don't know what you mean by auto truncate by template/field, but you have all information available in your hook: // /site/ready.php $wire->addHookAfter('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments(0); $page->template; // yourtemplate $page->yourfield; // yourvalue if($page->template == 'foo') $page->bar = 'yournewvalue'; }); You need to save all existing pages. That's easy using TracyDebugger + Console: $pages = $pages->find('yourselector'); $all = $pages->count(); foreach($pages as $i=>$p) { l("saving page $i/$all id $p"); $p->save(); } If you have lots of pages you might run into execution timeouts and need to do that in batches (by appending ",sort=id,id>xxx" to your selector to skip already updated pages. Or you could only select non-updated pages via "yournewfield=" (empty) in your selector.
  19. Thx @wbmnfktr, this is not what I need ? if($options['returnRelative']) { $filename = str_replace($options['_startPath'], '', $filename); } It only removes the startpath but does not list a relative path to the pw root. I've added a little tweak to make this possible: It would be a simple addition to $config->urls/paths in /wire/core/Paths.php: Edit: Just created a PR for that. If this feature is already there please tell me so that I can close the PR. Otherwise please like it to support this request, thx ? https://github.com/processwire/processwire/pull/142
  20. It's not only about CSS, it's also about injecting custom scripts that are somewhere in any folder... We have $files->find(...) to easily find all .js files in a folder, the returned array holds all file paths and to add those files to $config->scripts you need to convert all those paths to relative urls. I'm sure there is an easy way somewhere...
  21. Hi folks, I find myself very often doing things like this: $file = __FILE__; // eg /var/www/mywebsite/site/templates/mystyle.css $url = str_replace($config->paths->root, $config->urls->root, $file); echo "<link rel='stylesheet' type='text/css' href='$url'>"; Is ther no easier way of doing that? This is quite error-prone because I've had issues with modules where I did replace $config->paths->root by "/" and then it didn't work on subfolder installations... I would like to have something like this: <link rel='stylesheet' type='text/css' href='<?= $config->urls(__FILE__) ?>'> I've created such a helper method whenever I needed it in my modules. But I need it almost in all of my modules, so I think this should be in the core if it is not already. And I'm sure I'm not the only one dealing with conversion of file paths to file urls relative to the pw root! Thanks for your help! Edit: Actually it's not as simple as doing a str_replace because this fails on Windows because __FILE__ is something like C:\www\mywebsite\site\templates\myfile.css and $config->paths->root is C:/www/my...
  22. I guess you could do a CSS solution: https://www.google.at/search?q=css+truncate+multiline+text&oq=css+truncate&aqs=chrome.1.69i57j0l5.4338j0j4&sourceid=chrome&ie=UTF-8 Or you could also create custom labels via a hook: // /site/ready.php $wire->addHookAfter('Pages::saveReady(template=yourtemplate)', function(HookEvent $event) { $page = $event->arguments(0); $page->yourcustomlabel = $this->sanitizer->truncate($page->yourtextarea, 150); });
  23. I agree that this is a challenge. I also find the Mystique approach very interesting! Did you see my approach of migrations? From the docs: Migrations are shipped with the module in /site/modules/YourModule/RockMigrations/XXX.php // 0.0.5.php <?php namespace ProcessWire; /** * Änderungen für neues Feld "Kundenstatus" */ $upgrade = function(RockMigrations $rm) { $rm->createField('ernum', 'text', [ "label" => "ER-Nummer", ]); $rm->addFieldToTemplate('ernum', 'rockprojecteffort', 'cost_gross'); }; $downgrade = function(RockMigrations $rm) { $rm->deleteField('ernum'); }; I can then just do: git pull $rm = $modules->get('RockMigrations'); $rm->setModule('YourModule'); $rm->up('0.0.5'); It's not at all complete yet, but it works well on several production projects and simplified my workflow a lot! Here an example of a more complex migration (that is IMHO still self expanatory and easy to create and manage): <?php namespace ProcessWire; /** * tweaks */ $upgrade = function(RockMigrations $rm) { $rm->setFieldData('invoiceto', ["labelFieldFormat" => "{rockcontact_parent}, {title}, E-Mail = {rockcontact_email}"], 'rockproject'); $rm->installModule('Prozesse'); $rm->installModule('ProcessProzesse'); $rm->installModule('Rechnungsfreigaben'); $rm->installModule('ProcessRechnungsfreigaben'); $rm->addPermissionsToRoles( ['prozesse','prozesse-rechnungsfreigaben'], ['office-management', 'senior'] ); $rm->createField('iscurrent', 'checkbox', [ 'label' => 'Ist der aktuellste von mehreren Einträgen', 'collapsed' => Inputfield::collapsedNo, ]); $rm->addFieldToTemplate('iscurrent', 'invoiceconfirmation'); foreach($this->pages->find('template=invoiceconfirmation') as $p) $p->save(); }; $downgrade = function(RockMigrations $rm) { $rm->deleteField('iscurrent'); $rm->uninstallModule('ProcessRechnungsfreigaben'); $rm->uninstallModule('Rechnungsfreigaben'); $rm->uninstallModule('ProcessProzesse'); $rm->uninstallModule('Prozesse'); $rm->setFieldData('invoiceto', ["labelFieldFormat" => "{rockcontact_parent}, {title}"], 'rockproject'); }; You see that it makes task that are usually tedious via the API very easy. The first line (setFieldData for invoiceto) sets new field settings in template context, for example. IMHO the way to go are migrations. The mystique approach looks very interesting indeed, but it will not work in all scenarios (eg when you need to manage/edit/install/uninstall modules or templates or roles and permissions. @LostKobrakai had a reason for developing his module and it took me quite long to understand that ? I just didn't like the implementation a lot due to the reasons mentioned in the docs of RockMigrations. Said that I have to admit that RockMigrations is also still a very early stage implementation of would would be necessary in my opinion. I think PW would strongly need a solid API to handle all those migration stuff properly and easily. Something that makes it easy to migrate between different module versions, upgrade modules, downgrade modules, revert changes, check for compatibility before installation and so on. Something that maybe even automatically syncs the module versions with the migration versions (so that your code is always in sync with your DB, otherwise it would be possible that your code requests a field that does not exist in the DB yet). If that worked all we would have to do would be a "git pull" and pw would take care of the rest. My module is kind of a quick and dirty implementation of that dream, but it works quite well ?
  24. Snippet to easily add Inputfields with intellisense support ? "Get PW Inputfield": { "prefix": "field", "body": [ "/** @var Inputfield$1 \\$${2:f} */", "\\$${2:f} = \\$this->modules->get('Inputfield$1');" ], "description": "Get PW Inputfiel" }, PS: Turns out that the chaining syntax as shown in the demo does not properly work with intellisense, so I'll use single line method calls in the future ?
×
×
  • Create New...