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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 5.0.1

- `Moment.locale`: returns `false` instead of throwing when Moment is not loaded yet.
- `BSDateRangePicker`: removed debug `print`s (config on each render and the selected range on each change).

- Tests:
- New `bones_ui_bootstrap_unloaded_test.dart`: `Moment.locale` with Moment not loaded.
- VM: no debug prints in `BSDateRangePicker`; stale-library check ignores directories with only hidden files
(e.g. `.DS_Store` left by git when switching branches).

## 5.0.0

- **Bootstrap 5** (5.3.7). For Bootstrap 4 use version `4.x` (branch `4.x`).
Expand Down
8 changes: 7 additions & 1 deletion lib/src/bones_ui_bootstrap_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ class Moment {
}

/// Sets the locale of [Moment].
///
/// Returns `false` if [locale] is empty or if [Moment] is not loaded yet
/// (it triggers [load]; `await Moment.load()` before calling it).
static bool locale(String locale) {
load();

Expand All @@ -279,7 +282,10 @@ class Moment {

locale = locale.replaceFirst('_', '-');

_moment!.callMethod<JSAny?>('locale'.toJS, locale.toJS);
var moment = _moment;
if (moment == null) return false;

moment.callMethod<JSAny?>('locale'.toJS, locale.toJS);
return true;
}

Expand Down
4 changes: 0 additions & 4 deletions lib/src/components/daterangepicker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ class BSDateRangePicker extends UIComponent implements UIField<Pair<DateTime>> {
if (configLocale.isNotEmpty) 'locale': configLocale,
};

print(config);

JQuery.$(
_textElement,
).call('daterangepicker', [config.toJSDeep, _jsQueryCallback.toJS]);
Expand Down Expand Up @@ -296,8 +294,6 @@ class BSDateRangePicker extends UIComponent implements UIField<Pair<DateTime>> {
_startTime = startTime;
_endTime = endTime;

print('Selected Date Range: $startTime >> $endTime');

_updateTextElement();

onChange.add(this);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bones_ui_bootstrap
description: Adds Bootstrap 5 support to Dart package bones_ui, allowing use of Bootstrap components and CSS.
version: 5.0.0
version: 5.0.1
homepage: https://github.com/Colossus-Services/bones_ui_bootstrap

environment:
Expand Down
15 changes: 15 additions & 0 deletions test/bones_ui_bootstrap_consistency_vm_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,17 @@ void main() {
});

test('no stale bundled library versions', () {
// Ignores directories with only hidden files (e.g. `.DS_Store`), left
// behind by git when switching branches:
bool hasFiles(Directory d) => d
.listSync(recursive: true)
.whereType<File>()
.any((f) => !f.uri.pathSegments.last.startsWith('.'));

List<String> dirs(String prefix) => Directory('lib')
.listSync()
.whereType<Directory>()
.where(hasFiles)
.map((d) => d.uri.pathSegments.where((s) => s.isNotEmpty).last)
.where((n) => n.startsWith(prefix))
.toList();
Expand Down Expand Up @@ -165,4 +173,11 @@ void main() {
}
});
});

test('no debug prints in BSDateRangePicker', () {
var source = File(
'lib/src/components/daterangepicker.dart',
).readAsStringSync();
expect(source, isNot(contains('print(')));
});
}
30 changes: 30 additions & 0 deletions test/bones_ui_bootstrap_unloaded_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@TestOn('browser')
library;

import 'dart:js_interop_unsafe';

import 'package:bones_ui_bootstrap/bones_ui_bootstrap.dart';
import 'package:test/test.dart';
import 'package:web_utils/web_utils.dart';

/// Tests with the JS libraries NOT loaded (nothing is loaded in this file
/// before the checks).
void main() {
group('Without loaded JS libraries', () {
test('nothing loaded', () {
expect(Moment.isLoaded, isFalse);
expect(JQuery.isLoaded, isFalse);
expect(Bootstrap.isLoaded, isFalse);
expect(globalContext['jQuery'], isNull);
});

test('Moment.locale: not loaded yet', () async {
expect(Moment.locale(' '), isFalse);
// Triggers the load, but doesn't throw:
expect(Moment.locale('en'), isFalse);

expect(await Moment.load(), isTrue);
expect(Moment.locale('en'), isTrue);
});
});
}
Loading