~ubuntu-branches/ubuntu/trusty/freeipa/trusty

« back to all changes in this revision

Viewing changes to install/ui/src/freeipa/search.js

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2013-06-17 22:15:21 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130617221521-z8zya289o8xgrv3u
Tags: 3.2.1-0ubuntu1
* Merge from unreleased debian git
  - rebase to 3.2.1
  - add ipa-client-automount to freeipa-client, and patch it so it
    works on Debian/Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
        './jquery',
27
27
        './phases',
28
28
        './reg',
 
29
        './spec_util',
29
30
        './text',
30
31
        './facet'],
31
 
    function(IPA, $, phases, reg, text) {
 
32
    function(IPA, $, phases, reg, su, text, mod_facet) {
32
33
 
33
34
var exp = {};
34
35
 
35
 
IPA.search_facet = function(spec, no_init) {
36
 
 
37
 
    spec = spec || {};
38
 
 
39
 
    spec.name = spec.name || 'search';
40
 
    spec.managed_entity = spec.managed_entity ? IPA.get_entity(spec.managed_entity) : spec.entity;
41
 
 
42
 
    spec.disable_breadcrumb =
43
 
        spec.disable_breadcrumb === undefined ? true : spec.disable_breadcrumb;
44
 
    spec.disable_facet_tabs =
45
 
        spec.disable_facet_tabs === undefined ? true : spec.disable_facet_tabs;
 
36
exp.search_facet_control_buttons_pre_op = function(spec, context) {
46
37
 
47
38
    spec.actions = spec.actions || [];
48
39
    spec.actions.unshift(
77
68
    spec.state.evaluators.push(
78
69
        IPA.selected_state_evaluator,
79
70
        IPA.self_service_state_evaluator);
 
71
    return spec;
 
72
};
 
73
 
 
74
exp.search_facet_pre_op = function(spec, context) {
 
75
 
 
76
    var entity = context.entity;
 
77
    su.context_entity(spec, context);
 
78
 
 
79
    spec.name = spec.name || 'search';
 
80
    spec.title = spec.title || entity.metadata.label;
 
81
    spec.label = spec.label || entity.metadata.label;
 
82
    spec.tab_label = spec.tab_label || '@i18n:facets.search';
 
83
 
 
84
    spec.managed_entity = spec.managed_entity ? IPA.get_entity(spec.managed_entity) : spec.entity;
 
85
 
 
86
    spec.disable_breadcrumb =
 
87
        spec.disable_breadcrumb === undefined ? true : spec.disable_breadcrumb;
 
88
    spec.disable_facet_tabs =
 
89
        spec.disable_facet_tabs === undefined ? true : spec.disable_facet_tabs;
 
90
 
 
91
    exp.search_facet_control_buttons_pre_op(spec, context);
 
92
    return spec;
 
93
};
 
94
 
 
95
IPA.search_facet = function(spec, no_init) {
 
96
 
 
97
    spec = spec || {};
80
98
 
81
99
    var that = IPA.table_facet(spec, true);
82
100
 
337
355
        batch.on_success = function(data, text_status, xhr) {
338
356
            that.facet.refresh();
339
357
            that.facet.on_update.notify([],that.facet);
340
 
            IPA.notify_success('@i18n:search.deleted');
 
358
            var succeeded = batch.commands.length - batch.errors.errors.length;
 
359
            var msg = text.get('@i18n:search.deleted').replace('${count}', succeeded);
 
360
            IPA.notify_success(msg);
341
361
        };
342
362
 
343
363
        batch.on_error = function() {
352
372
    return that;
353
373
};
354
374
 
 
375
exp.nested_search_facet_preop = function(spec, context) {
 
376
 
 
377
    var entity = context.entity;
 
378
    su.context_entity(spec, context);
 
379
 
 
380
    spec.name = spec.name || 'search';
 
381
    spec.title = spec.title || entity.metadata.label_singular;
 
382
    spec.label = spec.label || entity.metadata.label;
 
383
    spec.tab_label = spec.tab_label || '@i18n:facets.search';
 
384
 
 
385
    spec.managed_entity = spec.nested_entity;
 
386
 
 
387
    spec.disable_breadcrumb = false;
 
388
    spec.disable_facet_tabs = false;
 
389
 
 
390
    exp.search_facet_control_buttons_pre_op(spec, context);
 
391
    return spec;
 
392
};
 
393
 
355
394
/*TODO.  this has much copied code from above.  Refactor the search_facet
356
395
To either be nested or not nested. */
357
 
IPA.nested_search_facet = function(spec) {
 
396
exp.nested_search_facet = IPA.nested_search_facet = function(spec) {
358
397
 
359
398
    spec = spec || {};
360
399
 
361
 
    spec.managed_entity = IPA.get_entity(spec.nested_entity);
362
 
 
363
 
    spec.disable_breadcrumb = false;
364
 
    spec.disable_facet_tabs = false;
365
 
 
366
400
    var that = IPA.search_facet(spec);
367
401
 
368
402
    that.show = function() {
514
548
exp.register = function() {
515
549
 
516
550
    var a = reg.action;
 
551
    var f = reg.facet;
517
552
 
518
553
    a.register('batch_remove', IPA.batch_remove_action);
519
554
    a.register('add', IPA.add_action);
520
555
    a.register('batch_items', IPA.batch_items_action);
521
556
    a.register('batch_disable', IPA.batch_disable_action);
522
557
    a.register('batch_enable', IPA.batch_enable_action);
 
558
 
 
559
    f.register({
 
560
        type: 'search',
 
561
        factory: IPA.search_facet,
 
562
        pre_ops: [
 
563
            exp.search_facet_pre_op
 
564
        ]
 
565
    });
 
566
 
 
567
    f.register({
 
568
        type: 'nested_search',
 
569
        factory: IPA.nested_search_facet,
 
570
        pre_ops: [
 
571
            exp.nested_search_facet_preop
 
572
        ]
 
573
    });
523
574
};
524
575
 
525
576
phases.on('registration', exp.register);