Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added edit-panel component #1224

Merged
merged 13 commits into from
Apr 19, 2023
11 changes: 11 additions & 0 deletions .eslint-todo-errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,17 @@
{ "ruleId": "ember/no-test-this-render", "line": 506, "column": 3 },
{ "ruleId": "hbs/check-hbs-template-literals", "line": 506, "column": 15 }
],
"tests/integration/components/flexberry-edit-panel-test.js": [
{ "ruleId": "ember/no-test-module-for", "line": 13, "column": 1 },
{ "ruleId": "ember/no-test-this-render", "line": 108, "column": 3 },
{ "ruleId": "hbs/check-hbs-template-literals", "line": 108, "column": 15 },
{ "ruleId": "ember/no-test-this-render", "line": 137, "column": 3 },
{ "ruleId": "hbs/check-hbs-template-literals", "line": 137, "column": 15 },
{ "ruleId": "ember/no-test-this-render", "line": 168, "column": 3 },
{ "ruleId": "hbs/check-hbs-template-literals", "line": 168, "column": 15 },
{ "ruleId": "ember/no-test-this-render", "line": 216, "column": 3 },
{ "ruleId": "hbs/check-hbs-template-literals", "line": 216, "column": 15 }
],
"tests/integration/components/flexberry-error-test.js": [
{ "ruleId": "ember/no-test-module-for", "line": 4, "column": 1 },
{ "ruleId": "ember/no-test-this-render", "line": 9, "column": 3 },
Expand Down
10 changes: 8 additions & 2 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ module.exports = {
"no-quoteless-attributes"
]
},
{
"moduleId": "app/templates/components/flexberry-edit-panel",
"only": [
// don't delete, exception for text in button.
"block-indentation"
]
},
{
"moduleId": "app/templates/components/filters-dialog-content",
"only": [
Expand Down Expand Up @@ -528,8 +535,7 @@ module.exports = {
"moduleId": "tests/dummy/app/templates/ember-flexberry-dummy-suggestion-edit",
"only": [
"eol-last",
"quotes",
"simple-unless"
"quotes"
]
},
{
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
* `flexberry-edit-panel` component for responsive edit panel buttons.
* Generated `flexberry-edit-panel` to edit form blueprint.

## [3.8.0-beta.18] - 2023-03-15
### Fixed
Expand Down
16 changes: 16 additions & 0 deletions addon/components/button-dropdown-menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import FlexberryBaseComponent from 'ember-flexberry/components/flexberry-base-component';

export default FlexberryBaseComponent.extend({
classNames: ['button-dropdown-menu', 'menu'],

actions: {
/**
* Call action of a clicked button.
*/
sendButtonAction() {
/* eslint-disable ember/closure-actions */
this.sendAction('sendButtonAction', ...arguments);
/* eslint-enable ember/closure-actions */
pepelyaeva marked this conversation as resolved.
Show resolved Hide resolved
}
}
});
94 changes: 94 additions & 0 deletions addon/components/flexberry-button-dropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
@module ember-flexberry
*/

import FlexberryBaseComponent from 'ember-flexberry/components/flexberry-base-component';
import { assert } from '@ember/debug';
import { isNone } from '@ember/utils';

export default FlexberryBaseComponent.extend({

classNames: ['ui dropdown group-toolbar'],

classNameBindings: ['readonly:disabled'],

title: '',

elementId: undefined,

/**
* menu buttons.
* @example
* `
* buttons: [
* {
* action: actionName,
* text: buttonText,
* disabled: buttonDisabled
* class: '.button-class'
* }, {
* action: {
* name: 'actionName',
* params: ['paramValue1', 'paramValue2']
* },
* text: buttonText,
* disabled: buttonDisabled
* class: '.button-class'
* }, {
* text: buttonText,
* disabled: buttonDisabled
* buttons: [{
* action: actionName,
* text: buttonText,
* disabled: buttonDisabled
* class: '.button-class'
* }, {
* action: actionName,
* text: buttonText,
* disabled: buttonDisabled
* class: '.button-class'
* }]
* },
* ]
* `
*/
buttons: undefined,

/**
* Flag, the component is embedded in another component, for example, in the flexberry-olv toolbar.
* Set to send action in the controller.
* @type {Boolean}
*/
deepMount: false,

actions: {
/**
* Call action of a clicked button.
*
* @method actions.sendButtonAction
* @public
* @param {String|Object} action action.
*/
sendButtonAction(action) {
assert('{{button-dropdown}}: button.action parameter missing', !isNone(action));

let actionName = '';
let actionParams = [];

if (typeof action === 'string') {
actionName = action;
} else if (!isNone(action.params)) {
actionName = action.name;
actionParams = action.params;
}

if (this.get('deepMount')) {
this.currentController.send(actionName, ...actionParams);
} else {
/* eslint-disable ember/closure-actions */
this.sendAction(actionName, ...actionParams);
/* eslint-enable ember/closure-actions */
}
}
}
});
Loading