Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pasturestack/api-explorer",
"version": "1.1.21",
"version": "1.1.22",
"private": true,
"description": "Embedded PastureStack explorer for compatible API services",
"author": "Original contributors and PastureStack maintainers",
Expand Down
49 changes: 26 additions & 23 deletions partials/field.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div class="field-editor {{#ifInList type 'array,map'}}field-composite{{/ifInList}}">
{{#ifInList type 'array,map'}}
{{#each children}}
<div class="dualValue">
Expand All @@ -18,22 +19,22 @@
{{/if}}

{{#ifInList type 'string,date,base64,dnsLabel,dnsLabelRestricted,hostname'}}
<input type="text" class="form-control" name="{{formFieldName}}" value="{{value}}" placeholder="{{placeholder}}"/>
<input type="text" class="form-control" name="{{formFieldName}}" aria-label="{{name}}" value="{{value}}" placeholder="{{placeholder}}"/>
{{/ifInList}}

{{#ifEqual type 'json'}}
<textarea class="form-control" name="{{formFieldName}}">{{value}}</textarea>
<textarea class="form-control" name="{{formFieldName}}" aria-label="{{name}}">{{value}}</textarea>
{{/ifEqual}}

{{#ifInList type 'password,masked'}}
<input type="password" class="form-control" name="{{formFieldName}}" value="{{value}}" placeholder="{{placeholder}}" />
<input type="password" class="form-control" name="{{formFieldName}}" aria-label="{{name}}" value="{{value}}" placeholder="{{placeholder}}" />
{{/ifInList}}

{{#ifInList type 'number,int,float'}}
<input
type="number"
class="form-control"
name="{{formFieldName}}"
name="{{formFieldName}}" aria-label="{{name}}"
value="{{value}}"
placeholder="{{placeholder}}"
{{#ifEqual field.min undefined}} {{else}} min="{{field.min}}"{{/ifEqual}}
Expand All @@ -43,23 +44,23 @@
{{/ifInList}}

{{#ifEqual type "blob"}}
<input type="file" class="form-control" name="{{formFieldName}}" />
<input type="file" class="form-control" name="{{formFieldName}}" aria-label="{{name}}" />
{{/ifEqual}}

{{#ifEqual type "boolean"}}
{{#if field.nullable}}
<select name="{{formFieldName}}" class="form-select">
<select name="{{formFieldName}}" aria-label="{{name}}" class="form-select">
<option value="__-*NULL*-__" {{#ifEqual null ../value}} SELECTED{{/ifEqual}}>NULL</option>
<option value="" {{#ifEqual false ../value}} SELECTED{{/ifEqual}}>false</option>
<option value="1" {{#ifEqual true ../value}} SELECTED{{/ifEqual}}>true</option>
</select>
{{else}}
<input type="checkbox" class="form-control" name="{{formFieldName}}" value="1" {{#if value}} CHECKED{{/if}} />
<input type="checkbox" class="form-control" name="{{formFieldName}}" aria-label="{{name}}" value="1" {{#if value}} CHECKED{{/if}} />
{{/if}}
{{/ifEqual}}

{{#ifEqual type "enum"}}
<select name="{{formFieldName}}" class="form-select">
<select name="{{formFieldName}}" aria-label="{{name}}" class="form-select">
{{#if field.nullable}}
<option value="__-*NULL*-__">NULL</option>
{{/if}}
Expand All @@ -71,7 +72,7 @@

{{#ifEqual type "reference"}}
{{#if field.options}}
<select name="{{formFieldName}}" class="form-select">
<select name="{{formFieldName}}" aria-label="{{name}}" class="form-select">
{{#if field.nullable}}
<option value="__-*NULL*-__">NULL</option>
{{/if}}
Expand All @@ -84,12 +85,12 @@
{{/ifInMap}}
</select>
{{else}}
<input type="text" class="form-control" name="{{formFieldName}}" value="{{value}}">
<input type="text" class="form-control" name="{{formFieldName}}" aria-label="{{name}}" value="{{value}}">
{{/if}}
{{/ifEqual}}

{{#ifEqual type "__type__"}}
<select name="{{formFieldName}}" class="form-select" onchange="htmlapi.createTypeChanged($(this).val());">
<select name="{{formFieldName}}" aria-label="{{name}}" class="form-select" onchange="htmlapi.createTypeChanged($(this).val());">
{{#each field.options}}
<option value="{{this}}" {{#ifEqual this ../value}} SELECTED{{/ifEqual}}>{{this}}</option>
<!-- {{this}} , {{../value}} -->
Expand All @@ -101,21 +102,23 @@
</span>
{{/if}}

{{#if enlargeable}}
<a class="btn btn-secondary btn-sm btn-inline" onclick="htmlapi.switchToTextarea(this);" tabindex="-1" title="Enlarge"><i class="bi bi-arrows-fullscreen"></i></a>
{{/if}}

{{#if nullCheck}}
<div class="nullcheck">
<label>
<input type="checkbox" name="{{formFieldNameNull}}" value="1" tabindex="-1" onclick="htmlapi.toggleNull(this);" {{#ifEqual null value}} CHECKED{{/ifEqual}}>NULL
</label>
</div>
{{/if}}
<div class="field-tools">
{{#if nullCheck}}
<div class="nullcheck">
<label title="{{t 'nullValueHelp'}}">
<input type="checkbox" name="{{formFieldNameNull}}" value="1" onclick="htmlapi.toggleNull(this);" {{#ifEqual null value}} CHECKED{{/ifEqual}}>NULL
</label>
</div>
{{/if}}
{{#if enlargeable}}
<button type="button" class="field-enlarge" onclick="htmlapi.switchToTextarea(this);" title="{{t 'enlarge'}}"><i class="bi bi-arrows-fullscreen" aria-hidden="true"></i><span>{{t 'enlarge'}}</span></button>
{{/if}}
</div>

{{#unless addingField}}
{{#ifInList type 'array,map'}}
<a class="btn btn-secondary btn-sm btn-inline" tabindex="-1" onclick="htmlapi.subAdd(this,'{{name}}');"><i class="bi bi-plus"></i></a>
</div>
{{/ifInList}}
{{/unless}}

</div>
2 changes: 1 addition & 1 deletion scripts/ci
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ for (const section of ['dependencies', 'optionalDependencies']) {
}
}
}
if (pkg.version !== '1.1.21') {
if (pkg.version !== '1.1.22') {
fail('PACKAGE_RELEASE_VERSION_UNEXPECTED', `actual=${pkg.version}`);
}
if (!pkg.engines || pkg.engines.node !== '24.22.3') {
Expand Down
35 changes: 20 additions & 15 deletions src/HTMLApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ HTMLApi.prototype.setModalActions = function(actions)
this._reqModal._actions = actions;
var html = '';

actions.forEach(function(action) {
// Keep visual and keyboard order aligned without mutating action ownership.
var displayActions = actions.slice().sort(function(a, b) {
return (a.cancel ? -1 : a.primary ? 1 : 0) - (b.cancel ? -1 : b.primary ? 1 : 0);
});
displayActions.forEach(function(action) {
var color = 'btn-secondary';
var btnType = 'button'
if ( action.primary ) {
Expand Down Expand Up @@ -540,8 +544,8 @@ HTMLApi.prototype.actionLoad = function(name, obj, body)

var html = Handlebars.templates['edit.hbs'](tpl);
var popinActions = [
{id: 'ok', text: 'Show Request', primary: true, onClick: function() { self.showRequest(mode,'POST',actionInput,retry,url); }.bind(self) },
{id: 'cancel', text: 'Cancel', cancel: true }
{id: 'ok', text: window.PastureStackI18n.text('showRequest'), primary: true, onClick: function() { self.showRequest(mode,'POST',actionInput,retry,url); }.bind(self) },
{id: 'cancel', text: window.PastureStackI18n.text('cancel'), cancel: true }
];


Expand Down Expand Up @@ -973,7 +977,7 @@ HTMLApi.prototype.request = function(method,body,opt,really)
if ( really )
{
this.setModalActions([
{id: 'cancel', text: 'Cancel', cancel: true}
{id: 'cancel', text: window.PastureStackI18n.text('cancel'), cancel: true}
]);

$('#notsent').hide();
Expand Down Expand Up @@ -1045,12 +1049,12 @@ HTMLApi.prototype.request = function(method,body,opt,really)

var actions = [];

actions.push({id: 'ok', text: 'Send Request', primary: true, onClick: function() { self.request(method,body,opt,true); } });
actions.push({id: 'ok', text: window.PastureStackI18n.text('sendRequest'), primary: true, onClick: function() { self.request(method,body,opt,true); } });

if ( this._lastOpt && this._lastOpt.retry )
actions.push({id: 'edit', text: 'Back to Edit', onClick: this._lastOpt.retry.bind(this,body) });
actions.push({id: 'edit', text: window.PastureStackI18n.text('backToEdit'), onClick: this._lastOpt.retry.bind(this,body) });

actions.push({id: 'cancel', text: 'Cancel', cancel: true});
actions.push({id: 'cancel', text: window.PastureStackI18n.text('cancel'), cancel: true});

self.showModal(html, {
destroyOnClose: false,
Expand Down Expand Up @@ -1123,7 +1127,7 @@ HTMLApi.prototype.requestDone = function(err, body, res)
var popinActions = [
{id: 'reload', text: 'Reload', onClick: this.reload.bind(this)},
{id: 'up', text: 'Go Up', onClick: function() { this.up(); }.bind(this) },
{id: 'cancel', text: 'Close', cancel: true}
{id: 'cancel', text: window.PastureStackI18n.text('close'), cancel: true}
];

if ( loc )
Expand Down Expand Up @@ -1324,12 +1328,12 @@ HTMLApi.prototype.showEdit = function(data,update,schema,url)
self.showEdit(body||self._lastRequestBody||data, update, schema, url);
}

var title = (update ? 'Edit' : 'Create') +' '+ schema.id;
var title = window.PastureStackI18n.text(update ? 'edit' : 'create') +' '+ schema.id;
var html = Handlebars.templates['edit.hbs'](tpl);
var method = (update ? 'PUT' : 'POST');
var popinActions = [
{id: 'ok', text: 'Show Request', primary: true, onClick: function() { self.showRequest(mode, method,schema,retry,url); }.bind(self) },
{id: 'cancel', text: 'Cancel', cancel: true }
{id: 'ok', text: window.PastureStackI18n.text('showRequest'), primary: true, onClick: function() { self.showRequest(mode, method,schema,retry,url); }.bind(self) },
{id: 'cancel', text: window.PastureStackI18n.text('cancel'), cancel: true }
];

self.showModal(html, {
Expand Down Expand Up @@ -1857,19 +1861,20 @@ HTMLApi.prototype.toggleNull = function(check)
HTMLApi.prototype.switchToTextarea = function(button)
{
var $button = $(button);
var $par = $($button.parent());
var $input = $('INPUT[type="text"]', $par);
var $par = $button.closest('.field-editor');
if ( !$par.length ) $par = $button.parent();
var $input = $('INPUT[type="text"]:not(.key)', $par).first();

if ( !$input[0] )
return;

var val = $input.val();

var $textarea = $('<textarea>', {name: $input.attr('name') }).addClass('form-control expandedTextarea');
var $textarea = $('<textarea>', {name: $input.attr('name'), 'aria-label': $input.attr('aria-label'), placeholder: $input.attr('placeholder') }).addClass('form-control expandedTextarea');
$input.replaceWith($textarea);
$textarea.val(val);
$textarea.on('keydown', function(e) { if ( e.keyCode == 13 ) { e.stopPropagation(); return true; } });
$button.hide();
$button.remove();
}

HTMLApi.prototype.setLocalCookie = function(on,min) {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

var messages = {
"en-US": {
sendRequest: "Send Request", backToEdit: "Back to Edit", showRequest: "Show Request", cancel: "Cancel", close: "Close", enlarge: "Enlarge", nullValueHelp: "Send an explicit null value",
operations: "Operations", up: "Up", reload: "Reload", create: "Create",
edit: "Edit", remove: "Delete", actions: "Actions", none: "None",
filter: "Filter", sortBy: "Sort By", notSorted: "(Not Sorted)",
Expand All @@ -22,6 +23,7 @@
selectedCount: "items are selected", language: "Language", explorerView: "Explorer View"
},
"zh-TW": {
sendRequest: "送出請求", backToEdit: "返回編輯", showRequest: "檢視請求", cancel: "取消", close: "關閉", enlarge: "展開", nullValueHelp: "傳送明確的 null 值",
operations: "操作", up: "上一層", reload: "重新載入", create: "建立",
edit: "編輯", remove: "刪除", actions: "動作", none: "無",
filter: "篩選", sortBy: "排序欄位", notSorted: "(未排序)",
Expand Down
Loading