mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) updates from grist-core
This commit is contained in:
@@ -5,6 +5,7 @@ const dom = require('app/client/lib/dom');
|
||||
const kd = require('app/client/lib/koDom');
|
||||
const koDomScrolly = require('app/client/lib/koDomScrolly');
|
||||
const {renderAllRows} = require('app/client/components/Printing');
|
||||
const {isNarrowScreen} = require('app/client/ui2018/cssVars');
|
||||
|
||||
require('app/client/lib/koUtil'); // Needed for subscribeInit.
|
||||
|
||||
@@ -17,6 +18,7 @@ const {RowContextMenu} = require('../ui/RowContextMenu');
|
||||
const {parsePasteForView} = require("./BaseView2");
|
||||
const {columnInfoTooltip} = require("../ui/tooltips");
|
||||
|
||||
|
||||
/**
|
||||
* DetailView component implements a list of record layouts.
|
||||
*/
|
||||
@@ -75,6 +77,7 @@ function DetailView(gristDoc, viewSectionModel) {
|
||||
|
||||
//--------------------------------------------------
|
||||
// Set up DOM event handling.
|
||||
this._twoLastFieldIdsSelected = [null, null];
|
||||
|
||||
// Clicking on a detail field selects that field.
|
||||
this.onEvent(this.viewPane, 'mousedown', '.g_record_detail_el', function(elem, event) {
|
||||
@@ -82,6 +85,8 @@ function DetailView(gristDoc, viewSectionModel) {
|
||||
var rowModel = this.recordLayout.getContainingRow(elem, this.viewPane);
|
||||
var field = this.recordLayout.getContainingField(elem, this.viewPane);
|
||||
commands.allCommands.setCursor.run(rowModel, field);
|
||||
this._twoLastFieldIdsSelected.unshift(field.id());
|
||||
this._twoLastFieldIdsSelected.pop();
|
||||
});
|
||||
|
||||
// Double-clicking on a field also starts editing the field.
|
||||
@@ -89,6 +94,18 @@ function DetailView(gristDoc, viewSectionModel) {
|
||||
this.activateEditorAtCursor();
|
||||
});
|
||||
|
||||
// We authorize single click only on the value to avoid conflict with tooltip
|
||||
this.onEvent(this.viewPane, 'click', '.g_record_detail_value', function(elem, event) {
|
||||
var field = this.recordLayout.getContainingField(elem, this.viewPane);
|
||||
if (
|
||||
this._twoLastFieldIdsSelected[0] === this._twoLastFieldIdsSelected[1]
|
||||
&& !isNarrowScreen()
|
||||
&& this._canSingleClick(field)
|
||||
) {
|
||||
this.activateEditorAtCursor();
|
||||
}
|
||||
});
|
||||
|
||||
//--------------------------------------------------
|
||||
// Instantiate CommandGroups for the different modes.
|
||||
this.autoDispose(commands.createGroup(DetailView.generalCommands, this, this.viewSection.hasFocus));
|
||||
@@ -430,4 +447,20 @@ DetailView.prototype._duplicateRows = async function() {
|
||||
this.setCursorPos({rowId: addRowIds[0]})
|
||||
}
|
||||
|
||||
DetailView.prototype._canSingleClick = function(field) {
|
||||
// we can't simple click if :
|
||||
// - the field is a formula
|
||||
// - the field is toggle (switch or checkbox)
|
||||
if (
|
||||
field.column().isRealFormula() || field.column().hasTriggerFormula()
|
||||
|| (
|
||||
field.column().pureType() === "Bool"
|
||||
&& ["Switch", "CheckBox"].includes(field.column().visibleColFormatter().widgetOpts.widget)
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = DetailView;
|
||||
|
||||
@@ -46,7 +46,7 @@ import {DocTutorial} from 'app/client/ui/DocTutorial';
|
||||
import {isTourActive} from "app/client/ui/OnBoardingPopups";
|
||||
import {IPageWidget, toPageWidget} from 'app/client/ui/PageWidgetPicker';
|
||||
import {linkFromId, selectBy} from 'app/client/ui/selectBy';
|
||||
import {startWelcomeTour} from 'app/client/ui/welcomeTour';
|
||||
import {startWelcomeTour} from 'app/client/ui/WelcomeTour';
|
||||
import {IWidgetType} from 'app/client/ui/widgetTypes';
|
||||
import {PlayerState, YouTubePlayer} from 'app/client/ui/YouTubePlayer';
|
||||
import {isNarrowScreen, mediaSmall, mediaXSmall, testId, theme} from 'app/client/ui2018/cssVars';
|
||||
|
||||
Reference in New Issue
Block a user